我可能有 2 个 Controller
1-ControllerBLUE.controller(默认)
2-ControllerRED.controller
如何从脚本更改 Controller
我尝试过:
var colorController = GetComponent(Animator);
colorController.runtimeAnimatorController = Resources.Load("main/colors/controllercolors/ControllerRED.controller ") as RuntimeAnimatorController;
但它不起作用,只是让动画 Controller 变为:“无(运行时动画 Controller )”
这可能吗?我怎样才能让它发挥作用?
最佳答案
抱歉,我在 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 () {
} }
关于animation - 通过脚本更改动画 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27329808/