文档

Unity Engine

Download Unity

Unity Engine

SetBlendShapeWeight(int, float)

Sets the weight of a blend shape for this renderer.
阅读时间1 分钟最后更新于 1 天前

Definition

  • Type: Method
  • Namespace: UnityEngine
  • Assembly: UnityEngine.CoreModule
public void SetBlendShapeWeight(int index, float value)

Parameters

index

The index of the blend shape to modify. The index must be smaller than the Sprite.blendShapeCount of the sprite attached to this renderer.

value

The weight for this blend shape.

Remarks

The weight of a blend shape represents how much the sprite has been blended (or morphed) from its original shape to a target blend shape. The target blend shape is another sprite containing the same topology, but with different vertex positions than the original.
The blend shape weight range includes values between the minimum and the maximum weights defined in the sprite.
Unity performs sprite blend shape deformation on the GPU using a compute shader. For blend shapes to take effect, set SpriteRenderer.drawMode to SpriteDrawMode.Simple and set PlayerSettings.meshDeformation to MeshDeformation.GPU or MeshDeformation.GPUBatched. To do this in the Unity Editor, in the main menu, go to Edit > Project Settings > Player > Other Settings, then set GPU Skinning to GPU (Batched) or GPU.
Important: Unity ignores blend shape weights if GPU Skinning is set to CPU, or if the platform doesn't support blend shape deformation in compute shaders. For example, the Web Player doesn't support compute shaders when it uses the WebGL2 graphics API rather than WebGPU.
Note that blend shape deformation does not update Renderer.bounds or Renderer.localBounds.
Additional Resources: SpriteRenderer.GetBlendShapeWeight.