public static void ScreenGameViewContent() { string uniquePathForName = ScreenShots.GetUniquePathForName("ContentExample"); Application.CaptureScreenshot(uniquePathForName); Debug.Log(string.Format("Saved screenshot at {0}", uniquePathForName)); }
private static string SaveScreenShot(int width, int height, Color[] pixels, string name) { Texture2D texture2D = new Texture2D(width, height); texture2D.SetPixels(pixels, 0); texture2D.Apply(true); byte[] bytes = texture2D.EncodeToPNG(); UnityEngine.Object.DestroyImmediate(texture2D, true); string uniquePathForName = ScreenShots.GetUniquePathForName(name); File.WriteAllBytes(uniquePathForName, bytes); Debug.Log(string.Format("Saved screenshot at {0}", uniquePathForName)); return(uniquePathForName); }