如何在运行时将动画控制器添加到角色?
How to add a Animator Controller to a character at runtime?
我在 "Assets/Resources/System/PLController" 有一个 Animator 控制器。我必须在运行时使用脚本添加它。如何做到这一点。使用 Unity 5 (5.3.0f4)
PLController =(动画控制器)
首先将一个 Animator
组件附加到那个 GameObject
就像
声明一个 Animator
变量。
通过GetComponent
赋值变量
将 RuntimeAnimatorController
分配给它的 runtimeAnimatorController
属性。
喜欢,
Animator PLAnimator;
void Start ()
{
PLAnimator = GetComponent<Animator> ();
PLAnimator.runtimeAnimatorController = Resources.Load ("Assets/Resources/System/PLController") as RuntimeAnimatorController;
}
我在 "Assets/Resources/System/PLController" 有一个 Animator 控制器。我必须在运行时使用脚本添加它。如何做到这一点。使用 Unity 5 (5.3.0f4)
PLController =(动画控制器)
首先将一个 Animator
组件附加到那个 GameObject
就像
声明一个
Animator
变量。通过
GetComponent
赋值变量
将
RuntimeAnimatorController
分配给它的runtimeAnimatorController
属性。
喜欢,
Animator PLAnimator;
void Start ()
{
PLAnimator = GetComponent<Animator> ();
PLAnimator.runtimeAnimatorController = Resources.Load ("Assets/Resources/System/PLController") as RuntimeAnimatorController;
}