x


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?

more ▼

asked Dec 11 '10 at 04:22 PM

erikw gravatar image

erikw
3 2 2 2

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

I just answered a similar question over here... http://answers.unity3d.com/questions/201049/image-inventory.html

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. ;)

more ▼

answered Feb 28 '12 at 11:24 PM

KrisCadle gravatar image

KrisCadle
194 1 3 7

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x324
x104

asked: Dec 11 '10 at 04:22 PM

Seen: 940 times

Last Updated: Feb 28 '12 at 11:24 PM