Merge pull request #1525 from ousttrue/fix/AssignHumanoid_index_check

null index check
This commit is contained in:
ousttrue
2022-02-14 17:25:58 +09:00
committed by GitHub

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");
}
}
}