IEnumerator ProcessPicture()
{
// We should only read the screen after all rendering is complete
yield return new WaitForEndOfFrame
();
// Create a texture the size of the screen, RGB24 format
int width = Screen.width;
int height = Screen.height;
var tex
= new Texture2D
(width, height, TextureFormat
.RGB24,
false);
// Read screen contents into the texture
tex
.ReadPixels(new Rect
(0,
0, width, height
),
0,
0); tex.Apply();
// Encode texture into PNG
byte[] bytes = tex.EncodeToPNG();
//Destroy(tex);
StartCoroutine(UploadPicture(bytes));
}
IEnumerator UploadPicture(byte[] b)
{
yield return new WaitForSeconds
(1);
TNManager.SaveFile("filename" , b);
}