#pragma warning disable 618 void Update() { if (runScript && umaData) { umaData.boneHashList = new Dictionary <int, UMAData.BoneData>(); Transform[] umaBones = boneStructure.gameObject.GetComponentsInChildren <Transform>(); umaData.tempBoneData = new UMAData.BoneData[umaBones.Length]; for (int i = 0; i < umaBones.Length; i++) { UMAData.BoneData tempBone = new UMAData.BoneData(); tempBone.boneTransform = umaBones[i]; tempBone.originalBonePosition = umaBones[i].localPosition; tempBone.originalBoneRotation = umaBones[i].localRotation; tempBone.originalBoneScale = umaBones[i].localScale; umaData.boneHashList.Add(UMASkeleton.StringToHash(umaBones[i].name), tempBone); umaData.tempBoneData[i] = tempBone; //Only while Dictionary can't be serialized } Debug.Log(umaData.boneHashList.Count + " bones have been included"); ReplaceAnimatedBones(); } runScript = false; }
private void AddBonesRecursive(Transform transform) { var hash = UMASkeleton.StringToHash(transform.name); boneHashData[hash] = new UMAData.BoneData() { boneTransform = transform, originalBonePosition = transform.localPosition, originalBoneScale = transform.localScale, originalBoneRotation = transform.localRotation }; for (int i = 0; i < transform.childCount; i++) { var child = transform.GetChild(i); AddBonesRecursive(child); } }