- Home /
Screenshot only with specified cameras
Hi everyone,
I want to take a screenshot of my game. BUT I want to limit the screenshot to specific cameras. AND while the screenshot is taken, the user should not see any changes to the game. There should be a camera shutter effect on the UI, but that should not be part of the screenshot.
In this example, I have 4 cameras:
Camera 1 renders the cube on Layer A. Clear Flag: Skybox
Camera 2 renders the 2 cylinders on Layer B. Clear Flag: Depth Only
Camera 3 renders the 1st User Interface (Canvas 1) on Layer C. Clear Flag: Depth Only
Camera 4 renders the 2nd User Interface (Canvas 2) on Layer D. Clear Flag: Depth Only
I only want the screenshot to include Camera 1, 2 and 3.
Here's what the player should see during gaming:
Here's what the screenshot should look like after it was taken and saved:
Answer by matthewseaward · Aug 25, 2015 at 02:55 PM
Have you tried just disabling the cameras you don't need? Put it into a coroutine and it should be fine. I needed something similar - I only wanted to take a screenshot from one camera in a fixed point but not the GUI and main camera.
IEnumerator Screenshot()
{
// Disable unrequired cameras
mainCamera.enabled = false;
GUICamera.enabled=false;
// Enable the camera to take a screenshot with
photographer.enabled=true;
yield return new WaitForFixedUpdate();
GetComponent<AudioSource>().PlayOneShot (shutter);
int width = Screen.width;
int height = Screen.height;
Texture2D tex = new Texture2D(width, height, TextureFormat.RGB24,false);
yield return new WaitForFixedUpdate();
tex.ReadPixels(new Rect(0,0,width, height), 0,0);
tex.Apply();
// Do whatever with screenshot
Destroy (tex);
mainCamera.enabled = true;
GUICamera.enabled=true;
photographer.enabled=false;
yield return (0);
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612001327im_/https://answers.unity.com/themes/thub/images/avi.jpg)