null index check

This commit is contained in:
ousttrue
2022-02-14 16:42:49 +09:00
parent 67fa87bb62
commit cdbd669db0

View File

@@ -61,9 +61,21 @@ namespace UniVRM10
static void AssignHumanoid(List<VrmLib.Node> 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");
}
}
}