Hi,
I’m trying to get screenshots via IO except of Application.screenCapture. I’m using example from documentation:
function takeSnapShot (){
print("Taking snap...");
yield new WaitForEndOfFrame ();
// Create a texture the size of the screen, RGB24 format
var tex = new Texture2D (128, 128, TextureFormat.RGB24, false);
// Read screen contents into the texture
tex.ReadPixels (Rect(0, 0, Screen.width, Screen.height), 0, 0);
tex.Apply ();
// Encode texture into PNG
var bytes = tex.EncodeToPNG();
Destroy (tex);
// Write to a file in the project folder
File.WriteAllBytes(Application.dataPath+"/externalData/smini"+currDataBlock+".png", bytes);
print("Snap taken!");
}
And there is a problem - with yield function screenshot is never taken - console stops with “Taking snap…”, without yield screenshot is taken, but it’s grey, blank texture (size and format are correct). I’m not familiar with I/O so any help and advice is welcome.
Kind regards,
Artur