通过脚本更改动画控制器

时间:2014-12-06 08:31:29

标签: animation unity3d unityscript unity3d-2dtools

我有2个控制器可能

1-ControllerBLUE.controller(默认)

2-ControllerRED.controller

如何从脚本

更改控制器

我试过了:

var colorController = GetComponent(Animator);


 colorController.runtimeAnimatorController =   Resources.Load("main/colors/controllercolors/ControllerRED.controller ") as RuntimeAnimatorController;

但它不起作用它只是让动画师控制器:“无(运行时动画控制器)”

有可能吗?我怎样才能使它工作?

1 个答案:

答案 0 :(得分:3)

对不起,我在Unity中使用C#:

using UnityEngine;
using System.Collections;
public class ChangeController : MonoBehaviour {

Animator animator;

// Use this for initialization
void Start () {
    animator = gameObject.GetComponent<Animator>();
    animator.runtimeAnimatorController = Resources.Load("main/colors/controllercolors/ControllerRED") as RuntimeAnimatorController;
}

// Update is called once per frame
void Update () {

} }