Taking a sequence of screenshots

I want to take a sequence of screenshots that I render to a texture. Between every shot I want to rotate the mesh I'm "photographing".

To do this I've created a monobehaviour that I attached to the main camera. In Start() I set up the mesh and the object and call a coroutine like so:

StartCoroutine(RenderTexture());

And the function that is supposed to do all the work:

IEnumerator RenderTexture()
{
  for(int i=0; i<NumberScreenshots; i++)
  {
    //here the mesh is rotated and positioned
    yield return new WaitForEndOfFrame();
    GrabScreenshot();
  }
}

Note: this is not the complete code, I have a working GrabScreenshot() function, and I get a texture out to a file, just like I intend.

But: Only the first screenshot in the sequence is complete. The rest appear to be taken during rendering and not at the end of the frame. Why doesn't the coroutine properly yield for the end of the frame more than once? What am I doing wrong?

I just answered a similar question over here

I posted my script for taking screenshots in sequence and showing the latest one on a GUI texture. It waits until the Frame is rendered and then saves it outside the assets folder so you can use it different ways. :wink: