rahul
rahul

Reputation: 5

Taking screenshot of partial area in Unity?

My game lets you dress up your character. I would like to save off that image (but not the rest of the 800x600 screen) to a file. According to the help, I can use Application.CaptureScreen() to capture the full screen but how does one capture just one part of it?

Upvotes: 0

Views: 3946

Answers (1)

Mattias
Mattias

Reputation: 3907

If you want full control over what area you want to screenshot, I would recommend setting up a new camera with a RenderTexture. This will enable a more flexible way of controlling your composition for your screenshots. Like the Avatar Creator on Xbox360.

  1. Create a new camera and align it to fit the image and composition of choice.
  2. Add a RenderTexture
  3. Use ReadPixels to read from the RenderTexture into a Texture2D and save using EncodeToPNG.
  4. Save to disk or upload to server

http://docs.unity3d.com/Manual/class-RenderTexture.html

http://docs.unity3d.com/ScriptReference/Texture2D.EncodeToPNG.html

Upvotes: 3

Related Questions