Beispiel #1
0
        public static BlendShape Create(string name)
        {
            BlendShape blendShape = ScriptableObject.CreateInstance <BlendShape>();

            blendShape.name = name;
            return(blendShape);
        }
Beispiel #2
0
        public static void RebuildBlendShapes(SpriteMesh spriteMesh, Mesh mesh)
        {
            if (!mesh)
            {
                return;
            }

            if (!spriteMesh)
            {
                return;
            }

            BlendShape[] blendShapes = null;

            //SpriteMeshData spriteMeshData = LoadSpriteMeshData(spriteMesh);

            //if (spriteMeshData)
            {
                //blendShapes = spriteMeshData.blendshapes;
            }

            if (spriteMesh.sharedMesh.vertexCount != mesh.vertexCount)
            {
                return;
            }

            if (blendShapes != null)
            {
#if !(UNITY_5_0 || UNITY_5_1 || UNITY_5_2)
                List <string> blendShapeNames = new List <string>();

                mesh.ClearBlendShapes();

                Vector3[] from = mesh.vertices;

                for (int i = 0; i < blendShapes.Length; i++)
                {
                    BlendShape blendshape = blendShapes[i];

                    if (blendshape)
                    {
                        string blendShapeName = blendshape.name;

                        if (blendShapeNames.Contains(blendShapeName))
                        {
                            Debug.LogWarning("Found repeated BlendShape name '" + blendShapeName + "' in SpriteMesh: " + spriteMesh.name);
                        }
                        else
                        {
                            blendShapeNames.Add(blendShapeName);

                            for (int j = 0; j < blendshape.frames.Length; j++)
                            {
                                BlendShapeFrame l_blendshapeFrame = blendshape.frames[j];

                                if (l_blendshapeFrame && from.Length == l_blendshapeFrame.vertices.Length)
                                {
                                    //Vector3[] deltaVertices = GetDeltaVertices(from, l_blendshapeFrame.vertices);

                                    //mesh.AddBlendShapeFrame(blendShapeName, l_blendshapeFrame.weight, deltaVertices, null, null);
                                }
                            }
                        }
                    }
                }

                mesh.UploadMeshData(false);

                //EditorUtility.SetDirty(mesh);

                //HideMaterials(spriteMesh);
#endif
            }
        }