Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


SetBlendShapeWeight(int, float)

Sets the weight of a blend shape for this renderer.
Read time 1 minuteLast updated 4 days ago

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.
For blend shapes to take effect, set SpriteRenderer.drawMode to SpriteDrawMode.Simple. If you use a Sprite Skin component, GPU skinning must be enabled. To enable GPU skinning in the Unity Editor, from the main menu select Edit > Project Settings > Player > Other Settings, then set GPU Skinning to GPU (Batched) or GPU.
Sprite blend shape deformation is performed on the GPU using a compute shader. As a result, it's not supported on platforms that lack compute shader support, such as the Web Player (when using WebGL2 graphics API, rather than WebGPU).
Note that blend shape deformation does not update Renderer.bounds or Renderer.localBounds.
Additional Resources: SpriteRenderer.GetBlendShapeWeight.