Merge pull request #791 from ichi-23/ichi/fix_null_reference_root_nodes

scene.nodes が無い glTF ファイルを Import したときに null reference exception が発生していた問題を修正
This commit is contained in:
ousttrue 2021-03-17 14:28:33 +09:00 committed by GitHub
commit 0c19c63cac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 4 deletions

View File

@ -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();

View File

@ -133,6 +133,10 @@ namespace UniGLTF
//
public static void FixCoordinate(ImporterContext context, List<TransformWithSkin> nodes, IAxisInverter inverter)
{
if (context.GLTF.rootnodes == null)
{
return;
}
var globalTransformMap = nodes.ToDictionary(x => x.Transform, x => new PosRot
{
Position = x.Transform.position,