animation event can not trig in editor mode

Hi all,How can i trig the animation event in editor mode ,not in play mode?

Hi dreamerFlyer,

You cannot trigger AnimationEvent while you are not in play mode

Why do you want to do this in editor mode?

because of i want to preview the all the effect ,for example show the particle system at some animationNormaltime,or when gameobject moving in one animation ,change it,'s animationClip at the same time.And When i use AnimationMode.SampleAnimationClip,it only can control one animationclip,can not control mutil animation at the same time.So ,I can not preview all the effect at the same time.

SampleAnimationClip() won’t trigger AnimationEvent, it a simplified path like you said that sample only one clip.

The Animator can record and playback animation, but it does only record the animator, so if the animator trigger some other Unity system like Particule system, particules won’t playback.

We do exactly the same thing in the avatar previewer for transition and animation clip preview.

First you need to set the animator in record mode and then resample for the length that you need.

float stepTime = 0.02f;
float currentTime = 0.0f;
animator.StartRecording(-1);
animator.Update(0.0f);
while(currentTime  < 2.0f)
{
    animator.Update(stepTime);
}
animator.StopRecording();

and then you can playback what you just recorded, including AnimationEvent.

animator.StartPlayback();
...
animator.playbackTime = myTime;
animator.Update(0);
...
animator.StartPlayback();