- Home /
Problems sampling animation in editor
I try to sample an animation and render it into a rendertexture. Sampling starts when a button is clicked, so all code is inside a EditorWindow. This works fine with several methods as long as I only sample once.
So basically it does:
animation.SampleAnimation (gameObject, t);
camera.Render ();
Now this should iteratively called to sample the clip multiple times, render them into textures and stitch them together as a spritesheet. The first sampling produces correct results nd the following samples, even if called with different values of t, are producing the same image as the first one (but root motion is still applied, so it's the same pose at another position).
I thought this could be, that the sampling might be not directly done, but needs a new frame. I moved the sampling and rendering code to the EditorWindow's Update function, while the button triggers some states so that it begins working. Now the first and second image seem to be correct, but all preceding images are copies of the second. Because Update might be called much more often than the actual frame update ratio, I delayed the rendering to be done only every 1000 updates. Still same result.
For the sampling I tried different approaches like
animation.Sample()
animationClip.SampleAnimation(gameObject, t)
AnimationMode.SampleAnimationClip(gameObject, animationClip, t)
and calls to Repaint, SceneView.RepaintAll.
Need suggestions of other refreshing functions, sampling functions or delegating functions that are in sync with the scene window (and can be triggered to update in the editor).
Your answer
Follow this Question
Related Questions
How to use AnimationClip.SampleAnimation()? 0 Answers
EDITOR: How to Change Animation Curve Colors 0 Answers
Why is this doing it?,why is this moving? 0 Answers
Checking animation playing in ieunmerator. Is there a better way to do this? 1 Answer
Combine multiple animation transforms in one animation 0 Answers