public static void CaptureScreenShot(CaptureScreenShotCallbackMethod captureScreenShotCallback) { if (ReignServices.captureScreenShotCallback != null) { Debug.LogError("You must wait until CaptureScreenShot has finished!"); return; } ReignServices.captureScreenShotCallback = captureScreenShotCallback; RequestEndOfFrame(captureScreenShotEndOfFrame); }
private static void captureScreenShotEndOfFrame() { var width = Screen.width; var height = Screen.height; var texture = new Texture2D(width, height, TextureFormat.RGB24, false); texture.ReadPixels(new Rect(0, 0, width, height), 0, 0); texture.Apply(); var data = texture.EncodeToPNG(); GameObject.Destroy(texture); if (captureScreenShotCallback != null) { captureScreenShotCallback(data); } captureScreenShotCallback = null; }
public static void CaptureScreenShot(CaptureScreenShotCallbackMethod captureScreenShotCallback) { if (ReignServices.captureScreenShotCallback != null) { Debug.LogError("You must wait until CaptureScreenShot has finished!"); return; } ReignServices.captureScreenShotCallback = captureScreenShotCallback; RequestEndOfFrame(captureScreenShotEndOfFrame); }
private static void captureScreenShotEndOfFrame() { var width = Screen.width; var height = Screen.height; var texture = new Texture2D(width, height, TextureFormat.RGB24, false); texture.ReadPixels(new Rect(0, 0, width, height), 0, 0); texture.Apply(); var data = texture.EncodeToPNG(); GameObject.Destroy(texture); if (captureScreenShotCallback != null) captureScreenShotCallback(data); captureScreenShotCallback = null; }