Hello guys
Someone could help me fidn out where is the problem of UnityException: Transform child out of bounds? Code:
bone = new Transform[gameObject.transform.childCount];
bindPoses = new Matrix4x4[mesh.vertexCount];
boneWeights = new BoneWeight[mesh.vertexCount];
Vector3[] vertices = mesh.vertices;
AssetDatabase.SaveAssets();
Debug.Log("Bones: " + bone.Length + "BindBones: " + bindPoses.Length + " Weights: " + boneWeights.Length
);
for (int index = 0; index <= mesh.vertexCount; index++)
{
if(this.gameObject.transform.childCount > 0) {
bone[index] = this.gameObject.transform.GetChild(index); < ----"UnityException: Transform child out of bounds"----->
bone[index].transform.position = this.transform.TransformPoint(mesh.vertices[index]);
bindPoses[index] = bone[index].transform.worldToLocalMatrix * this.transform.localToWorldMatrix;
boneWeights[index].boneIndex0 = index;
boneWeights[index].weight0 = 1;
Debug.Log(bone[index].name);
}
}
Thanks for your time