List <string> GetDuplicatedPaths(Transform root)
        {
            List <string>             paths               = new List <string>(50);
            List <string>             duplicates          = new List <string>(50);
            List <SpriteMeshInstance> spriteMeshInstances = new List <SpriteMeshInstance>(50);

            root.GetComponentsInChildren <SpriteMeshInstance>(true, spriteMeshInstances);

            for (int i = 0; i < spriteMeshInstances.Count; i++)
            {
                SpriteMeshInstance spriteMeshInstance = spriteMeshInstances[i];

                if (spriteMeshInstance)
                {
                    string bonePath = SpriteMeshUtils.GetSpriteMeshPath(root, spriteMeshInstance);

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

            return(duplicates);
        }
        public static void SavePose(Skin skin, Transform root)
        {
            List <SpriteMeshInstance> skins = new List <SpriteMeshInstance>(50);

            root.GetComponentsInChildren <SpriteMeshInstance>(true, skins);

            SerializedObject   skin0s      = new SerializedObject(skin);
            SerializedProperty entriesProp = skin0s.FindProperty("m_SkinEntries");


            skin0s.Update();
            entriesProp.arraySize = skins.Count;

            for (int i = 0; i < skins.Count; i++)
            {
                SpriteMeshInstance spriteMeshInstance = skins[i];

                if (spriteMeshInstance)
                {
                    SerializedProperty element = entriesProp.GetArrayElementAtIndex(i);
                    element.FindPropertyRelative("path").stringValue          = SpriteMeshUtils.GetSpriteMeshPath(root, spriteMeshInstance);
                    element.FindPropertyRelative("skin").objectReferenceValue = spriteMeshInstance.spriteMesh;
                }
            }

            skin0s.ApplyModifiedProperties();
            List <SpriteMesh> faces = new List <SpriteMesh>(50);

            faces.AddRange(root.GetComponentInChildren <SpriteMeshAnimation>().frames);

            SerializedObject   face0s       = new SerializedObject(skin);
            SerializedProperty entriesProp1 = face0s.FindProperty("m_FaceEntries");


            face0s.Update();
            entriesProp1.arraySize = faces.Count;
            for (int i = 0; i < faces.Count; i++)
            {
                SpriteMesh faceMesh = faces[i];

                if (faceMesh)
                {
                    SerializedProperty element = entriesProp1.GetArrayElementAtIndex(i);
                    element.FindPropertyRelative("path").stringValue          = SpriteMeshUtils.GetSpriteMeshPath(root, root.GetComponentInChildren <SpriteMeshAnimation>());
                    element.FindPropertyRelative("skin").objectReferenceValue = faceMesh;
                }
            }



            face0s.ApplyModifiedProperties();
        }