private static void CollectAnimationCallBack(ICharacterState stateManager, PlayerEntity playerEntity) { try { SingletonManager.Get <DurationHelp>().ProfileStart(CustomProfilerStep.StateUpdateEventCollect); stateManager.CollectAnimationCallback((animationCommandType, fsmType) => { playerEntity.stateInterVar.AnimationCallbackCommands.Commands.Add( new KeyValuePair <short, float>(animationCommandType, fsmType)); }); stateManager.ClearAnimationCallback(); //动画回调 var firstPersonEvent = playerEntity.firstPersonModel.Value.GetComponent <AnimationClipEvent>(); if (firstPersonEvent != null) { foreach (KeyValuePair <short, AnimationEventParam> keyValuePair in firstPersonEvent.EventParams) { playerEntity.stateInterVar.FirstPersonAnimationEventCallBack.Commands.Add( new KeyValuePair <short, AnimationEventParam>(keyValuePair.Key, keyValuePair.Value)); } firstPersonEvent.EventParams.Clear(); } var thirdPersonEvent = playerEntity.thirdPersonModel.Value.GetComponent <AnimationClipEvent>(); if (thirdPersonEvent != null) { foreach (KeyValuePair <short, AnimationEventParam> keyValuePair in thirdPersonEvent.EventParams) { playerEntity.stateInterVar.ThirdPersonAnimationEventCallBack.Commands.Add( new KeyValuePair <short, AnimationEventParam>(keyValuePair.Key, keyValuePair.Value)); } thirdPersonEvent.EventParams.Clear(); } } finally { SingletonManager.Get <DurationHelp>().ProfileEnd(CustomProfilerStep.StateUpdateEventCollect); } }