• 使用AnimatorOverrideController动态更换animationclip注意事项


    http://www.ceeger.com/forum/read.php?tid=19138

    public AnimationClip clip;
    Animator anim;
    void Awake()
    {
        anim = GetComponent<Animator>();
    }
    void Start () {
        AnimatorOverrideController overrideController = new AnimatorOverrideController();
        overrideController.runtimeAnimatorController = anim.runtimeAnimatorController;
        overrideController["testCip"] = clip;
        anim.runtimeAnimatorController = overrideController;
    }

    这里一定要注意, overrideController["testCip"] = clip;里面的testClip不是状态机里面的状态名,而是实际要替换的clip的名字..... 


    也可以用AnimationClipPair得到clip的名字

    RuntimeAnimatorController tempController = anim.runtimeAnimatorController;
    AnimatorOverrideController overrideController = new AnimatorOverrideController();
    overrideController.runtimeAnimatorController = tempController;
    overrideController.PerformOverrideClipListCleanup();//<span style="color:#ff0000;">这个函数在U5.3和5.0都不存在应该是去掉了吧</span>
     
     
    overrideController[overrideController.clips[0].originalClip.name] = clip;
    overrideController[overrideController.clips[1].originalClip.name] = clip2;
     
    foreach (AnimationClipPair pairs in overrideController.clips)
    {
        Debug.Log(pairs.originalClip.name );
        if (pairs.overrideClip!=null)
        {
            Debug.Log(pairs.overrideClip.name );
        }
    }
     
    anim.runtimeAnimatorController = overrideController;


  • 相关阅读:
    php l练习(写着玩)
    位、字节、字
    ueditor上传图片时目录创建失败的问题解决方法
    tp5插入百度富文本编辑器UEditor
    PHP实现用户异地登录提醒功能的方法
    tp5知识点
    TP5语法
    微擎url
    微擎多图片上传
    微擎函数Iserializer和Iunserializer序列化函数
  • 原文地址:https://www.cnblogs.com/nafio/p/9137366.html
Copyright © 2020-2023  润新知