AvatarBuilder.BuildGenericAvatar

切换到手册
public static Avatar BuildGenericAvatar (GameObject go, string rootMotionTransformName);

参数

go变换层级视图的根对象。
rootMotionTransformName根运动变换的变换名称。如果为空,则表明未定义根运动,您必须亲自处理化身移动。

描述

创建新的通用化身。

根游戏对象下的所有变换组件都将作为该通用化身的一部分。

using UnityEngine;
using UnityEditor;

public class Example : MonoBehaviour { void Start() { GameObject activeGameObject = Selection.activeGameObject;

if (activeGameObject != null &amp;&amp; activeGameObject.GetComponent<Animator>() != null) { Avatar avatar = AvatarBuilder.BuildGenericAvatar(activeGameObject, ""); avatar.name = "InsertYourName"; Debug.Log(avatar.isHuman ? "is human" : "is generic");

Animator animator = activeGameObject.GetComponent<Animator>() as Animator; animator.avatar = avatar; } } }