When I call the ‘TakeScreenshot’ function i want it to take a screenshot and place it into a variable. I was looking at Application.CaptureScreenshot ()
but could not get it to work.
Any help would be much appreciated
var ScreenShot : Texture; //Screenshot here
function TakeScreenshot ()
{
//Screenshot Code here
}
CaptureScreenshot() is for saving to a file. For writing pixels from the screen to a texture, use ReadPixels:
void TakeScreenshot() {
ScreenShot = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, false);
ScreenShot.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0);
ScreenShot.Apply();
}
(This is for C# - you may need to modify it if you’re using Unityscript).