Unity-Animator零散记录5 StateMachineBehaviour状态机脚本学习

时间:2016-01-01 16:49:44   收藏:0   阅读:1933

首先这个脚本必须继承自StateMachineBehaviour

public class MySMB : StateMachineBehaviour
{
    public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        base.OnStateEnter(animator, stateInfo, layerIndex);

        Debug.Log("!!!");
    }
}

 

 

然后切到Animator面板,选择状态机里的任意状态,点击Add Behaviour即可挂载

技术分享

 

这时运行游戏,当状态机运行至Jump状态时,程序打出Log

技术分享

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!