Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public List<GameObject> bodiesMaleFairBlue = new List<GameObject>();
- [PropertyRange(0, "maxBodyValue"), OnValueChanged("SetClothes", true)]
- public int clothes;
- int maxBodyValue; // This is defined depending on the clothing color the user chooses. I didn't include this in the script as it's unnecessary.
- void SetClothes()
- {
- UpdateSkinnedMesh(npc.bodyMesh, bodiesMaleFairBlue[clothes].GetComponentInChildren<SkinnedMeshRenderer>());
- }
- // The issue doesn't come from this function as it's working great outside of Odin (during play time)
- void UpdateSkinnedMesh(SkinnedMeshRenderer mesh, SkinnedMeshRenderer newMesh)
- {
- // update mesh
- mesh.sharedMesh = newMesh.sharedMesh;
- Transform[] childrens;
- childrens = npc.GetComponentsInChildren<Transform> (true);
- // sort bones.
- Transform[] bones = new Transform[newMesh.bones.Length];
- for (int boneOrder = 0; boneOrder < newMesh.bones.Length; boneOrder++)
- {
- bones[boneOrder] = Array.Find<Transform>(childrens, c => c.name == newMesh.bones[boneOrder].name);
- }
- mesh.bones = bones;
- mesh.sharedMaterial = newMesh.sharedMaterial;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement