Advertisement
Guest User

Untitled

a guest
May 8th, 2021
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.10 KB | None | 0 0
  1. public List<GameObject> bodiesMaleFairBlue = new List<GameObject>();
  2.  
  3. [PropertyRange(0, "maxBodyValue"), OnValueChanged("SetClothes", true)]
  4. public int clothes;
  5.  
  6. 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.
  7.  
  8. void SetClothes()
  9. {
  10.     UpdateSkinnedMesh(npc.bodyMesh, bodiesMaleFairBlue[clothes].GetComponentInChildren<SkinnedMeshRenderer>());
  11. }
  12.  
  13. // The issue doesn't come from this function as it's working great outside of Odin (during play time)
  14. void UpdateSkinnedMesh(SkinnedMeshRenderer mesh, SkinnedMeshRenderer newMesh)
  15. {
  16.     // update mesh
  17.     mesh.sharedMesh = newMesh.sharedMesh;
  18.    Transform[] childrens;
  19.     childrens = npc.GetComponentsInChildren<Transform> (true);
  20.     // sort bones.
  21.     Transform[] bones = new Transform[newMesh.bones.Length];
  22.     for (int boneOrder = 0; boneOrder < newMesh.bones.Length; boneOrder++)
  23.     {
  24.         bones[boneOrder] = Array.Find<Transform>(childrens, c => c.name == newMesh.bones[boneOrder].name);
  25.     }
  26.  
  27.     mesh.bones = bones;
  28.     mesh.sharedMaterial = newMesh.sharedMaterial;
  29. }
  30.  
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement