public static IEnumerator CaptureToFileCoroutine(string fileName, int width, int height, TextureExporter.ImageFileFormat fileFormat = TextureExporter.ImageFileFormat.PNG, int JPGQuality = 100, List <Camera> cameras = null, List <Canvas> canvas = null, ScreenshotTaker.CaptureMode captureMode = ScreenshotTaker.CaptureMode.RENDER_TO_TEXTURE, int antiAliasing = 8, bool captureGameUI = true, ScreenshotTaker.ColorFormat colorFormat = ScreenshotTaker.ColorFormat.RGB, bool recomputeAlphaMask = false) { InitScreenshotTaker(); yield return(CaptureToTextureCoroutine(width, height, cameras, canvas, captureMode, antiAliasing, captureGameUI, colorFormat, recomputeAlphaMask)); // EXPORT if (TextureExporter.ExportToFile(m_ScreenshotTaker.m_Texture, fileName, fileFormat, JPGQuality)) { Debug.Log("Screenshot created : " + fileName); } else { Debug.LogError("Failed to create screenshot : " + fileName); } }
public static IEnumerator CaptureToTextureCoroutine(int width, int height, List <Camera> cameras = null, List <Canvas> canvas = null, ScreenshotTaker.CaptureMode captureMode = ScreenshotTaker.CaptureMode.RENDER_TO_TEXTURE, int antiAliasing = 8, bool captureGameUI = true, ScreenshotTaker.ColorFormat colorFormat = ScreenshotTaker.ColorFormat.RGB, bool recomputeAlphaMask = false) { InitScreenshotTaker(); // Create resolution item ScreenshotResolution captureResolution = new ScreenshotResolution(); captureResolution.m_Width = width; captureResolution.m_Height = height; // Create camera items List <ScreenshotCamera> screenshotCameras = new List <ScreenshotCamera>(); if (cameras != null) { foreach (Camera camera in cameras) { ScreenshotCamera scamera = new ScreenshotCamera(camera); screenshotCameras.Add(scamera); } } // Create the overlays items List <ScreenshotOverlay> screenshotCanvas = new List <ScreenshotOverlay>(); if (canvas != null) { foreach (Canvas c in canvas) { ScreenshotOverlay scanvas = new ScreenshotOverlay(c); screenshotCanvas.Add(scanvas); } } // Capture yield return(m_ScreenshotTaker.StartCoroutine(m_ScreenshotTaker.CaptureAllCoroutine(new List <ScreenshotResolution> { captureResolution }, screenshotCameras, screenshotCanvas, captureMode, antiAliasing, captureGameUI, colorFormat, recomputeAlphaMask))); }
/// <summary> /// Captures the game. /// The filename must be a valid full name. /// </summary> public static void Capture(string fileName, int width, int height, TextureExporter.ImageFileFormat fileFormat = TextureExporter.ImageFileFormat.PNG, int JPGQuality = 100, List <Camera> cameras = null, List <Canvas> canvas = null, ScreenshotTaker.CaptureMode captureMode = ScreenshotTaker.CaptureMode.RENDER_TO_TEXTURE, int antiAliasing = 8, bool captureGameUI = true, ScreenshotTaker.ColorFormat colorFormat = ScreenshotTaker.ColorFormat.RGB, bool recomputeAlphaMask = false) { InitScreenshotTaker(); m_ScreenshotTaker.StartCoroutine(CaptureCoroutine(fileName, width, height, fileFormat, JPGQuality, cameras, canvas, captureMode, antiAliasing, captureGameUI, colorFormat, recomputeAlphaMask)); }
public virtual IEnumerator CaptureInnerTextureCoroutine(RawImage texture, ScreenshotResolution desiredCaptureResolution, List <ScreenshotCamera> cameras, List <ScreenshotOverlay> overlays, ScreenshotTaker.CaptureMode captureMode, int antiAliasing = 8, bool captureGameUI = true, ScreenshotTaker.ColorFormat colorFormat = ScreenshotTaker.ColorFormat.RGB, bool recomputeAlphaMask = false, bool stopTime = false, bool restore = true) { // Compute the texture resolution ScreenshotResolution tempRes = new ScreenshotResolution(); yield return(m_ScreenshotTaker.StartCoroutine(ComputeInnerTextureSizeCoroutine(texture, desiredCaptureResolution.ComputeTargetWidth(), desiredCaptureResolution.ComputeTargetHeight(), tempRes))); // Capture the game view at the raw image resolution yield return(m_ScreenshotTaker.StartCoroutine(m_ScreenshotTaker.CaptureAllCoroutine(new List <ScreenshotResolution> { tempRes }, cameras, overlays, captureMode, antiAliasing, captureGameUI, colorFormat, recomputeAlphaMask, stopTime))); // Set raw image texture using the previously captured texture texture.texture = tempRes.m_Texture; }
public IEnumerator CaptureResolutionCoroutine(ScreenshotResolution captureResolution, List <Camera> cameras = null, List <Canvas> canvas = null, ScreenshotTaker.CaptureMode captureMode = ScreenshotTaker.CaptureMode.RENDER_TO_TEXTURE, int antiAliasing = 8, bool captureGameUI = true, ScreenshotTaker.ColorFormat colorFormat = ScreenshotTaker.ColorFormat.RGB, bool recomputeAlphaMask = false) { // Create camera items List <ScreenshotCamera> screenshotCameras = new List <ScreenshotCamera>(); if (cameras != null) { foreach (Camera camera in cameras) { ScreenshotCamera scamera = new ScreenshotCamera(camera); screenshotCameras.Add(scamera); } } // Create the overlays items List <ScreenshotOverlay> screenshotCanvas = new List <ScreenshotOverlay>(); if (canvas != null) { foreach (Canvas c in canvas) { ScreenshotOverlay scanvas = new ScreenshotOverlay(c); screenshotCanvas.Add(scanvas); } } yield return(StartCoroutine(CaptureAllCoroutine(new List <ScreenshotResolution> { captureResolution }, screenshotCameras, screenshotCanvas, captureMode, antiAliasing, captureGameUI, colorFormat, recomputeAlphaMask))); }
public virtual IEnumerator CaptureCoroutine(ScreenshotResolution desiredCaptureResolution, List <ScreenshotCamera> cameras, List <ScreenshotOverlay> overlays, ScreenshotTaker.CaptureMode captureMode, int antiAliasing = 8, bool captureGameUI = true, ScreenshotTaker.ColorFormat colorFormat = ScreenshotTaker.ColorFormat.RGB, bool recomputeAlphaMask = false, bool stopTime = false, bool restore = true) { m_ScreenshotTaker = GameObject.FindObjectOfType <ScreenshotTaker> (); // Capture all inner textures foreach (RawImage texture in m_Textures) { yield return(m_ScreenshotTaker.StartCoroutine(CaptureInnerTextureCoroutine(texture, desiredCaptureResolution, cameras, overlays, captureMode, antiAliasing, captureGameUI, colorFormat, recomputeAlphaMask, stopTime))); } // Capture the composition at the desired resolution size yield return(m_ScreenshotTaker.StartCoroutine(CaptureCompositionCoroutine(desiredCaptureResolution))); }
/// <summary> /// Captures the game with the specified width, height. /// The texture will be resized if needed to match the capture settings. /// </summary> public IEnumerator CaptureToTextureCoroutine(Texture2D texture, int width, int height, List <Camera> cameras = null, List <Canvas> canvas = null, ScreenshotTaker.CaptureMode captureMode = ScreenshotTaker.CaptureMode.RENDER_TO_TEXTURE, int antiAliasing = 8, bool captureGameUI = true, ScreenshotTaker.ColorFormat colorFormat = ScreenshotTaker.ColorFormat.RGB, bool recomputeAlphaMask = false) { // Check texture if (texture == null) { Debug.LogError("The texture can not be null. You must provide a texture initialized with any width and height."); yield break; } // Update resolution item ScreenshotResolution captureResolution = new ScreenshotResolution(width, height); captureResolution.m_Texture = texture; yield return(StartCoroutine(CaptureResolutionCoroutine(captureResolution, cameras, canvas, captureMode, antiAliasing, captureGameUI, colorFormat, recomputeAlphaMask))); }
public static IEnumerator CaptureCoroutine(string fileName, int width, int height, TextureExporter.ImageFileFormat fileFormat = TextureExporter.ImageFileFormat.PNG, int JPGQuality = 100, List <Camera> cameras = null, List <Canvas> canvas = null, ScreenshotTaker.CaptureMode captureMode = ScreenshotTaker.CaptureMode.RENDER_TO_TEXTURE, int antiAliasing = 8, bool captureGameUI = true, ScreenshotTaker.ColorFormat colorFormat = ScreenshotTaker.ColorFormat.RGB, bool recomputeAlphaMask = false) { // Create resolution item ScreenshotResolution captureResolution = new ScreenshotResolution(); captureResolution.m_Width = width; captureResolution.m_Height = height; captureResolution.m_FileName = fileName; // Create camera items List <ScreenshotCamera> screenshotCameras = new List <ScreenshotCamera> (); if (cameras != null) { foreach (Camera camera in cameras) { ScreenshotCamera scamera = new ScreenshotCamera(camera); screenshotCameras.Add(scamera); } } // Create the overlays items List <ScreenshotOverlay> screenshotCanvas = new List <ScreenshotOverlay> (); if (canvas != null) { foreach (Canvas c in canvas) { ScreenshotOverlay scanvas = new ScreenshotOverlay(c); screenshotCanvas.Add(scanvas); } } // Capture yield return(m_ScreenshotTaker.StartCoroutine(m_ScreenshotTaker.CaptureAllCoroutine(new List <ScreenshotResolution> { captureResolution }, screenshotCameras, screenshotCanvas, captureMode, antiAliasing, captureGameUI, colorFormat, recomputeAlphaMask))); // EXPORT if (TextureExporter.ExportToFile(captureResolution.m_Texture, fileName, fileFormat, JPGQuality)) { Debug.Log("Screenshot created : " + fileName); } else { Debug.LogError("Failed to create : " + fileName); } }