void Start()
{
StartCoroutine(ScreenShot(new Rect(0, 0, Screen.width, Screen.height)));
}
IEnumerator ScreenShot(Rect rect)
{
yield return new WaitForEndOfFrame();
Texture2D shot = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, false);
shot.ReadPixels(rect, 0,0);
shot.Apply();
byte [] bytes=shot.EncodeToPNG();
string filName=Application.dataPath+"/ss.png";
System.IO.File.WriteAllBytes(filName,bytes);
}
{
StartCoroutine(ScreenShot(new Rect(0, 0, Screen.width, Screen.height)));
}
IEnumerator ScreenShot(Rect rect)
{
yield return new WaitForEndOfFrame();
Texture2D shot = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, false);
shot.ReadPixels(rect, 0,0);
shot.Apply();
byte [] bytes=shot.EncodeToPNG();
string filName=Application.dataPath+"/ss.png";
System.IO.File.WriteAllBytes(filName,bytes);
}