示例#1
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;
                }
            }
        }
        static void Upgrade_001(SerializedObject spriteMeshSO)
        {
            spriteMeshSO.Update();

            SerializedProperty bindPosesProp = spriteMeshSO.FindProperty("bindPoses");

            for (int i = 0; i < bindPosesProp.arraySize; ++i)
            {
                SerializedProperty bindPoseProp = bindPosesProp.GetArrayElementAtIndex(i);
                bindPoseProp.FindPropertyRelative("color").colorValue = ColorRing.GetColor(i);
            }

            SerializedProperty pivotPointProp = spriteMeshSO.FindProperty("pivotPoint");
            SerializedProperty spriteProp     = spriteMeshSO.FindProperty("m_Sprite");
            Sprite             sprite         = spriteProp.objectReferenceValue as Sprite;

            if (sprite)
            {
                pivotPointProp.vector2Value = SpriteMeshUtils.GetPivotPoint(sprite);
            }

            spriteMeshSO.ApplyModifiedProperties();
        }