Anima2D.SpriteMeshCache.SetBlendShapeFrameWeight C# (CSharp) Method

SetBlendShapeFrameWeight() public method

public SetBlendShapeFrameWeight ( BlendShapeFrame blendShapeFrame, float weight, string undoName ) : void
blendShapeFrame BlendShapeFrame
weight float
undoName string
return void
		public void SetBlendShapeFrameWeight(BlendShapeFrame blendShapeFrame, float weight, string undoName)
		{
			if(selectedBlendshape &&
				blendShapeFrame &&
				weight >= 1f &&
				selectedBlendshape.frames.Contains(blendShapeFrame))
			{
				RegisterObjectUndo(selectedBlendshape, undoName);
				RegisterObjectUndo(blendShapeFrame, undoName);

				BlendShapeFrame other = null;

				foreach(BlendShapeFrame f in selectedBlendshape.frames)
				{
					if(f != blendShapeFrame && f.weight == weight)
					{
						other = f;
						break;
					}
				}

				if(other)
				{
					DeleteBlendShapeFrame(selectedBlendshape, other, undoName);
				}

				blendShapeFrame.weight = weight;

				SortBlendshapeFrames(selectedBlendshape);

				m_DirtyVertices = true;
				isDirty = true;
			}
		}

Usage Example

Beispiel #1
0
 void OnFrameChanged(BlendShapeFrame blendShapeFrame, float weight)
 {
     spriteMeshCache.SetBlendShapeFrameWeight(blendShapeFrame, weight, "Set weight");
 }