Capturing a screenshot not working.

I wanted to add a screenshot taker in my unity project, but what surprised me was when I compiled it and ran it, there was nothing new in my application folder. I used 3 diffrent methods to try and save a screenshot, but nothing worked.

I moved the script onto my main camera to test it out, and I get lag every time it takes a screenshot, but there is no file at all. Is it just me or is it a known problem or something? Heres the code:

function Update () {

	//if user presses PrintScreen take a screenshot
	if(Input.GetKeyDown(KeyCode.Print)) {
		PRINTSCREEN();
	}
	else if (Input.GetKeyDown(KeyCode.Escape)) {
		Application.Quit();
	}
}
function PRINTSCREEN() {
	yield WaitForEndOfFrame();
	var SCREENSHOT = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, false);
	SCREENSHOT.ReadPixels(Rect(0,0,Screen.width, Screen.height),0,0);
	SCREENSHOT.Apply();
	
	var SCRN = SCREENSHOT.EncodeToPNG();
	Destroy(SCREENSHOT);
	
	//Doesn't work
	//Application.CaptureScreenshot(Application.dataPath + "/Screenshot.png");
	
	//Also doesn't work
	//var ENCSCRN:System.IO.BinaryWriter = new System.IO.BinaryWriter(System.IO.File.Open(Application.dataPath + "/Screenshot.png", System.IO.FileMode.Create));
	//ENCSCRN.Write(SCRN);
	//ENCSCRN.Close();
	
	//Also doesn't work
	System.IO.File.WriteAllBytes(Application.dataPath + "/Screenshots.png",SCRN);
}

What platform/OS? (See here for where Application.dataPath points to on the various supported platforms/targets.)

Oh yeah sorry, I run on windows 7, and the path I have should save a picture in “/Screenshot.png”. I even ran it as administrator to see if I didn’t give it write permission, but nothing.

The docs seem a little confusing on this point, but make sure you check both the folder with the .exe in it, and the ‘data’ folder.

(If it’s not being written to either of those places, then I’m not sure what the problem is. Maybe the docs aren’t up to date…)

Ive asked here and figured out that the printscreen button doesnt seem to work with it, but any other button should. The problem is now: why doesn’t the printscreen button work?

But thanks for your response, I know I wasn’t too descriptive.

function OnMouseDown()
{
Application.CaptureScreenshot(“Screenshot.png”);
}

Try this code to capture one png image of your game.