【问题标题】:How to add a Animator Controller to a character at runtime?如何在运行时将动画控制器添加到角色?
【发布时间】:2016-01-01 06:47:59
【问题描述】:

我在“Assets/Resources/System/PLController”中有一个 Animator 控制器。我必须在运行时使用脚本添加它。如何做到这一点。使用 Unity 5 (5.3.0f4)

PLController =(动画控制器)

【问题讨论】:

    标签: animation unity3d unity5


    【解决方案1】:

    首先将Animator 组件附加到GameObject

    • 声明一个Animator 变量。

    • 通过GetComponent分配变量

    • RuntimeAnimatorController 分配给其runtimeAnimatorController 属性。

    喜欢,

    Animator PLAnimator;
    
    void Start ()
        {
            PLAnimator = GetComponent<Animator> ();
            PLAnimator.runtimeAnimatorController = Resources.Load ("Assets/Resources/System/PLController") as RuntimeAnimatorController;
    }
    

    【讨论】:

    • 感谢@Hamza,它的作用就像一个魅力。
    • 此代码所在的文件的名称是什么? PLController.controller?
    • @PHPDeveloper 它自己的自定义类
    猜你喜欢
    • 2018-03-11
    • 2017-03-17
    • 1970-01-01
    • 1970-01-01
    • 2015-07-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多