首先这个脚本必须继承自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
时间: 2024-12-28 11:39:31