From d0a03c264b3ac6a48304a462f6488b184ee62829 Mon Sep 17 00:00:00 2001 From: ichi23 Date: Tue, 16 Mar 2021 19:48:24 +0900 Subject: [PATCH] added null check where GLTF.rootnodes is referenced --- Assets/UniGLTF/Runtime/UniGLTF/IO/ImporterContext.cs | 11 +++++++---- Assets/UniGLTF/Runtime/UniGLTF/IO/NodeImporter.cs | 4 ++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/ImporterContext.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/ImporterContext.cs index 991ce537c..facf12d47 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/ImporterContext.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/ImporterContext.cs @@ -145,11 +145,14 @@ namespace UniGLTF NodeImporter.SetupSkinning(this, nodes, i, inverter); } - // connect root - foreach (var x in GLTF.rootnodes) + if (GLTF.rootnodes != null) { - var t = nodes[x].Transform; - t.SetParent(Root.transform, false); + // connect root + foreach (var x in GLTF.rootnodes) + { + var t = nodes[x].Transform; + t.SetParent(Root.transform, false); + } } } await m_awaitCaller.NextFrame(); diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/NodeImporter.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/NodeImporter.cs index 541b4e034..940653521 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/NodeImporter.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/NodeImporter.cs @@ -133,6 +133,10 @@ namespace UniGLTF // public static void FixCoordinate(ImporterContext context, List nodes, IAxisInverter inverter) { + if (context.GLTF.rootnodes == null) + { + return; + } var globalTransformMap = nodes.ToDictionary(x => x.Transform, x => new PosRot { Position = x.Transform.position,