using System.Collections; using System.Collections.Generic; using UnityEngine; using EasyButtons; public class MeshCombine : MonoBehaviour { public SkinnedMeshRenderer target; public Transform sourceRootBone; public Transform[] bones; [Button] void Recalculate(){ target.rootBone = sourceRootBone; //target.bones = src.bones; Transform[] bonesT = new Transform[target.bones.Length]; for(int i = 0; i < target.bones.Length; i++){ Transform targetBone = target.bones[i]; string targetBoneName = targetBone.name; foreach(Transform sourceBone in sourceRootBone.GetComponentsInChildren()){ if(targetBoneName == sourceBone.name){ Debug.Log("Switching bone : " + targetBoneName ); bonesT[i] = sourceBone; break; } } } target.bones= bonesT; bones= target.bones; target.sharedMesh.RecalculateNormals(); target.sharedMesh.RecalculateBounds(); } [Button] void GetSelfRenderer(){ target = GetComponent(); } }