I'm trying to save the current game view into a texture with ReadPixels. This works when the game is running with:
Texture2D tex2d = new Texture2D(Screen.width,Screen.height,TextureFormat.RGB24,false);
tex2d.ReadPixels(new Rect(0,0,Screen.width,Screen.height),0,0,false);
tex2d.Apply();
However, it does not capture the game view when used from an EditorWindow. Pixels are read from the EditorWindow itself. How can we read pixels from the game view, when it is not running, using an editor script?
Edit: Application.CaptureScreenshot does a good job of capturing the game view from an EditorWindow into a file. How can we get similar results with ReadPixels?
↧