GetBonePath() public static method

public static GetBonePath ( Anima2D.Bone2D bone ) : string
bone Anima2D.Bone2D
return string
Exemplo n.º 1
0
        List <string> GetDuplicatedPaths(Transform root)
        {
            List <string> paths      = new List <string>(50);
            List <string> duplicates = new List <string>(50);
            List <Bone2D> bones      = new List <Bone2D>(50);

            root.GetComponentsInChildren <Bone2D>(true, bones);

            for (int i = 0; i < bones.Count; i++)
            {
                Bone2D bone = bones [i];

                if (bone)
                {
                    string bonePath = BoneUtils.GetBonePath(root, bone);

                    if (paths.Contains(bonePath))
                    {
                        duplicates.Add(bonePath);
                    }
                    else
                    {
                        paths.Add(bonePath);
                    }
                }
            }

            return(duplicates);
        }
Exemplo n.º 2
0
        public static void SavePose(Pose pose, Transform root)
        {
            List <Bone2D> bones = new List <Bone2D>(50);

            root.GetComponentsInChildren <Bone2D>(true, bones);

            SerializedObject   poseSO      = new SerializedObject(pose);
            SerializedProperty entriesProp = poseSO.FindProperty("m_PoseEntries");

            poseSO.Update();
            entriesProp.arraySize = bones.Count;

            for (int i = 0; i < bones.Count; i++)
            {
                Bone2D bone = bones [i];

                if (bone)
                {
                    SerializedProperty element = entriesProp.GetArrayElementAtIndex(i);
                    element.FindPropertyRelative("path").stringValue              = BoneUtils.GetBonePath(root, bone);
                    element.FindPropertyRelative("localPosition").vector3Value    = bone.transform.localPosition;
                    element.FindPropertyRelative("localRotation").quaternionValue = bone.transform.localRotation;
                    element.FindPropertyRelative("localScale").vector3Value       = bone.transform.localScale;
                }
            }

            poseSO.ApplyModifiedProperties();
        }
Exemplo n.º 3
0
        public void BindBone(Bone2D bone)
        {
            if (spriteMeshInstance && bone)
            {
                BindInfo bindInfo = new BindInfo();
                bindInfo.bindPose   = bone.transform.worldToLocalMatrix * spriteMeshInstance.transform.localToWorldMatrix;
                bindInfo.boneLength = bone.localLength;
                bindInfo.path       = BoneUtils.GetBonePath(bone);
                bindInfo.name       = bone.name;
                bindInfo.color      = ColorRing.GetColor(bindPoses.Count);

                if (!bindPoses.Contains(bindInfo))
                {
                    bindPoses.Add(bindInfo);

                    isDirty = true;
                }
            }
        }
Exemplo n.º 4
0
        public void BindBones()
        {
            if (spriteMeshInstance)
            {
                bindPoses.Clear();

                foreach (Bone2D bone in spriteMeshInstance.bones)
                {
                    if (bone)
                    {
                        BindInfo bindInfo = new BindInfo();

                        bindInfo.bindPose   = bone.transform.worldToLocalMatrix * spriteMeshInstance.transform.localToWorldMatrix;
                        bindInfo.boneLength = bone.localLength;
                        bindInfo.path       = BoneUtils.GetBonePath(bone);
                        bindInfo.name       = bone.name;

                        bindPoses.Add(bindInfo);
                    }
                }

                isDirty = true;
            }
        }