diff --git a/Assets/VRM10/Runtime/IO/Vrm10Importer.cs b/Assets/VRM10/Runtime/IO/Vrm10Importer.cs index c9951949c..2d0736c79 100644 --- a/Assets/VRM10/Runtime/IO/Vrm10Importer.cs +++ b/Assets/VRM10/Runtime/IO/Vrm10Importer.cs @@ -61,9 +61,21 @@ namespace UniVRM10 static void AssignHumanoid(List nodes, UniGLTF.Extensions.VRMC_vrm.HumanBone humanBone, VrmLib.HumanoidBones key) { + if (nodes == null) + { + throw new ArgumentNullException("nodes"); + } if (humanBone != null && humanBone.Node.HasValue) { - nodes[humanBone.Node.Value].HumanoidBone = key; + var index = humanBone.Node.Value; + if (index >= 0 && index < nodes.Count) + { + nodes[index].HumanoidBone = key; + } + else + { + throw new IndexOutOfRangeException("AssignHumanoid"); + } } }