go | 变换层级视图的根对象。 |
rootMotionTransformName | 根运动变换的变换名称。如果为空,则表明未定义根运动,您必须亲自处理化身移动。 |
创建新的通用化身。
根游戏对象下的所有变换组件都将作为该通用化身的一部分。
using UnityEngine; using UnityEditor;
public class Example : MonoBehaviour { void Start() { GameObject activeGameObject = Selection.activeGameObject;
if (activeGameObject != null && 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; } } }