- Home /
Other
(IMPORTANT!)How to make a high resolution screenshot including GUI?
I wanna make a high resolution screenshot at 1000*1500 and Application.CaptureScreenshot with superSize(and anti aliasing turned off) didn`t work for me so now I use this script from http://saadkhawaja.com/take-hi-resolution-screenshot-transparent-background/ :
public int resWidth = 2550;
public int resHeight = 3300;
private bool takeHiResShot = false;
public static string ScreenShotName(int width, int height) {
return string.Format("{0}/screen_{1}x{2}_{3}.png",
Application.dataPath,
width, height,
System.DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss"));
}
public void TakeHiResShot() {
takeHiResShot = true;
}
void LateUpdate() {
takeHiResShot |= Input.GetKeyDown("k");
if (takeHiResShot)
{
RenderTexture rt = new RenderTexture(resWidth, resHeight, 24);
camera.targetTexture = rt;
Texture2D screenShot = new Texture2D(resWidth, resHeight, TextureFormat.ARGB32, false);
camera.Render();
RenderTexture.active = rt;
screenShot.ReadPixels(new Rect(0, 0, resWidth, resHeight), 0, 0);
camera.targetTexture = null;
RenderTexture.active = null;
Destroy(rt);
byte[] bytes = screenShot.EncodeToPNG();
string filename = ScreenShotName(resWidth, resHeight);
System.IO.File.WriteAllBytes(filename, bytes);
Debug.Log(string.Format("Took screenshot to: {0}", filename));
Application.OpenURL(filename);
takeHiResShot = false;
}
}
It can make a screenshot at 1000*1500, but unfortunately the GUI is not included, so how can I make a high resolution screenshot including the GUI?
Answer by Jeffom · Sep 14, 2015 at 06:54 PM
Create a new camera that renders both the game and gui layers
Attach your screenshot component to the camera
Take Screenshot
This is a simple solution for your problem If you need to take a screenshot of your game running, keep the camera disabled and only enabled it for the screenshot process.
Edit: If you need to inglude OnGUI() on your screenshot
Try this: http://answers.unity3d.com/questions/31011/how-to-take-a-screenshot-that-includes-gui.html
Thanks, but how can I make a screenshot that is larger than my screen for example my screen is 320*480 and I want to make a screen shot that is 1000*1500 big??
Do you want to take the screenshot of objects outside the screen? or do you simply want to increase the image resolution?
@Jeffrom I want to increase the image resolution (so I can print it for example) And also include the GUI
@matyboy02 have you tried using this? http://docs.unity3d.com/ScriptReference/Screen.SetResolution.html
if you're using the editor you can try to change de window resolution in the window layout setting
No, Screen.SetResolution don't work :( and if I set the resolution in the editor to 1000*1500 the editor says: Using resolution 356*534. How can I fix this?
Follow this Question
Related Questions
Changing start scene gui size main menu 0 Answers
Relate font size to screen size in GUISkin 2 Answers
how to reduce library size? 2 Answers
Edit FontSettings from script 0 Answers
GUILabel wrong text wrapping when font changed by style 1 Answer