如何在运行时将动画控制器添加到角色? [英] How to add a Animator Controller to a character at runtime?
本文介绍了如何在运行时将动画控制器添加到角色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在资产/资源/系统/ PLController处有一个Animator控制器。我必须在运行时使用脚本将其添加。如何做到这一点。使用Unity 5(5.3.0f4)
I have an Animator controller at "Assets/Resources/System/PLController". I have to add it at runtime using a script. How to accomplish this. Using Unity 5 (5.3.0f4)
PLController =(动画控制器)
PLController = (Animator Controller)
推荐答案
首先将 Animator
组件附加到该 GameObject
,例如
First attach an Animator
component to that GameObject
like
-
声明一个
Animator
通过 GetComponent
将 RuntimeAnimatorController
分配给其 runtimeAnimatorController
属性。
像
Animator PLAnimator;
void Start ()
{
PLAnimator = GetComponent<Animator> ();
PLAnimator.runtimeAnimatorController = Resources.Load ("Assets/Resources/System/PLController") as RuntimeAnimatorController;
}
这篇关于如何在运行时将动画控制器添加到角色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文