#unity/日常积累 有时我们可能需要在编辑器中实现自己的动画播放预览,能够拖动播放,或者我们需要根据动画生成一些数据,比如生成GPU Skinning数据,这时我们就需要在非运行时播放动画。 实现该功能,我们只需要拿到AnimationClip对象,调用其[SampleAnimation](https://docs.unity3d.com/ScriptReference/AnimationClip.SampleAnimation.html)即可 ``` cs Animator animator = GetComponent(); AnimatorController ac = (AnimationController)animator.runtimeAnimatorController; AnimationClip[] clips = ac.animationClips; AnimationClip animClip = clips[0]; animClip.Sample(gameObject, animClip.length*0.5f);e ```