public static BlendShapeFrame CreateBlendShapeFrame(BlendShape blendshape, float weight, Vector3[] vertices) { BlendShapeFrame l_blendshapeFrame = null; if (blendshape && vertices != null) { l_blendshapeFrame = BlendShapeFrame.Create(weight, vertices); l_blendshapeFrame.hideFlags = HideFlags.HideInHierarchy; AssetDatabase.AddObjectToAsset(l_blendshapeFrame, blendshape); List <BlendShapeFrame> l_blendshapeFrames = new List <BlendShapeFrame>(blendshape.frames); l_blendshapeFrames.Add(l_blendshapeFrame); l_blendshapeFrames.Sort((a, b) => { return(a.weight.CompareTo(b.weight)); }); blendshape.frames = l_blendshapeFrames.ToArray(); EditorUtility.SetDirty(blendshape); EditorUtility.SetDirty(l_blendshapeFrame); } return(l_blendshapeFrame); }
public BlendShapeFrame CreateBlendShapeFrame(BlendShape blendshape, float weight, string undoName) { BlendShapeFrame frame = null; if (blendshape && weight >= 1f) { frame = BlendShapeFrame.Create(weight, ToVertices(GetTexVertices()).ToArray()); RegisterCreatedObjectUndo(frame, undoName); RegisterObjectUndo(blendshape, undoName); List <BlendShapeFrame> frames = new List <BlendShapeFrame>(blendshape.frames); frames.Add(frame); blendshape.frames = frames.ToArray(); SortBlendshapeFrames(blendshape); m_DirtyVertices = true; isDirty = true; } return(frame); }