Version: 2019.1
Opciones Adicionales para los Blend Trees (Árboles de Mezclas)
Animator Override Controllers

Working with blend shapes

Preparing the artwork

Once you have your blend shapes set up in your 3D modeling application (such as Autodesk® Maya®):

  1. In your 3D modeling application, enable these export settings:
    • Enable exporting animation.
    • Enable exporting blend shapes for deformed models.
  2. Export your selection to an FBX file.
  3. Import your FBX file into Unity.
  4. Select the newly imported Model in the Hierarchy window. The Inspector window displays the BlendShapes section containing all the blend shapes under the SkinnedMeshRenderer component.
  5. For each of the blend shapes listed, you can change its influence (weighting) to the default shape, where:
  6. 0 means the blend shape has no influence.
  7. 100 means the blend shape has full influence.

Create animations In Unity

To create a blend animation:

  1. Open the Animation window (from the main Unity menu: Window > Animation > Animation).
  2. On the left side of the window, click Add Curve and add a blend shape. The Inspector window displays the new blend shape in the BlendShapes section under the SkinnedMeshRenderer component.

Create the animation you want by adjusting the keyframes and blend weights.

To preview your animation, click Play in the Editor window or the Animation window.

Scripting access

You can also set the blend weights through scripting using functions like GetBlendShapeWeight and SetBlendShapeWeight.

To check how many blend shapes a Mesh has, use the blendShapeCount variable.

This code example demonstrates how to blend a default shape into two other blend shapes over time when attached to a GameObject with three or more blend shapes:

using UnityEngine;
using System.Collections;
 
public class BlendShapeExample : MonoBehaviour
{
    int blendShapeCount;
    SkinnedMeshRenderer skinnedMeshRenderer;
    Mesh skinnedMesh;
    float blendOne = 0f;
    float blendTwo = 0f;
    float blendSpeed = 1f;
    bool blendOneFinished = false;

    void Awake ()
    {
        skinnedMeshRenderer = GetComponent<SkinnedMeshRenderer> ();
        skinnedMesh = GetComponent<SkinnedMeshRenderer> ().sharedMesh;
    }

    void Start ()
    {
        blendShapeCount = skinnedMesh.blendShapeCount; 
    }

    void Update ()
    {
        if (blendShapeCount > 2) {
            if (blendOne < 100f) {
                skinnedMeshRenderer.SetBlendShapeWeight (0, blendOne);
                blendOne += blendSpeed;
            } else {
                blendOneFinished = true;
            }

            if (blendOneFinished == true && blendTwo < 100f) {
                skinnedMeshRenderer.SetBlendShapeWeight (1, blendTwo);
                blendTwo += blendSpeed;
            }
        }
    }
}
Opciones Adicionales para los Blend Trees (Árboles de Mezclas)
Animator Override Controllers
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961