1. 程式人生 > >Unity Animator StateMachineBehaviour(狀態機事件)

Unity Animator StateMachineBehaviour(狀態機事件)

繼承StateMachineBehaviour,以開始事件為例,重寫OnStateEnter方法:

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

此外,stateInfo.IsName(string),可以判斷當前播放的動畫。