/// <summary> /// Captures the game with the specified width, height, resolution upscale, and export it to the file fileName. /// </summary> public void Capture(int width, int height, int upscale, string fileName, List <Camera> cameras = null, List <Canvas> canvas = null, CaptureMode captureMode = CaptureMode.RENDER_TO_TEXTURE, int antiAliasing = 8, TextureExporter.ImageFormat imageFormat = TextureExporter.ImageFormat.PNG, int JPGQuality = 100, bool renderUI = true, bool playSound = false, ColorFormat colorFormat = ColorFormat.RGB, bool recomputeAlphaMask = false) { // Update resolution item m_CaptureResolution.m_Width = width; m_CaptureResolution.m_Height = height; m_CaptureResolution.m_Scale = upscale; m_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(true, c); screenshotCanvas.Add(scanvas); } } Capture(new List <ScreenshotResolution> { m_CaptureResolution }, screenshotCameras, screenshotCanvas, captureMode, antiAliasing, true, imageFormat, JPGQuality, renderUI, playSound, colorFormat, recomputeAlphaMask); }
protected IEnumerator UpdatePreviewCoroutine() { if (m_IsCapturing) { yield break; } m_IsCapturing = true; // Delegate call onCaptureBeginDelegate(); // Update resolutions m_PreviewList.Clear(); m_PreviewList.Add(GetFirstActiveResolution()); UpdateGameviewResolution(); UpdateResolutionFilenames(m_PreviewList); // Update overlays & guides m_PreviewOverlayList.Clear(); m_PreviewOverlayList.AddRange(m_Config.m_Overlays); if (m_Config.m_ShowGuidesInPreview) { m_GuidesOverlay = new ScreenshotOverlay(true, m_Config.m_GuideCanvas); m_PreviewOverlayList.Add(m_GuidesOverlay); ShowGuides(); } // Capture preview yield return(StartCoroutine(m_ScreenshotTaker.CaptureScreenshotsCoroutine(m_PreviewList, GetActiveCameras(), m_PreviewOverlayList, (m_Config.m_CaptureMode == ScreenshotTaker.CaptureMode.GAMEVIEW_RESIZING && m_Config.m_ResolutionCaptureMode == ScreenshotConfig.ResolutionMode.GAME_VIEW) ? ScreenshotTaker.CaptureMode.FIXED_GAMEVIEW : m_Config.m_CaptureMode, (int)m_Config.m_MultisamplingAntiAliasing, false, m_Config.m_Format, (int)m_Config.m_JPGQuality, m_Config.m_CaptureActiveUICanvas, false, m_Config.m_ColorFormat, m_Config.m_RecomputeAlphaLayer))); // Restore guides if (Application.isPlaying && m_Config.m_PreviewInGameViewWhilePlaying && m_Config.m_ShowGuidesInPreview) { ShowGuides(); } else { HideGuides(); } // Delegate call onCaptureEndDelegate(); m_IsCapturing = false; }
protected void InitIngamePreview() { m_PreviewOverlayList.Clear(); m_PreviewOverlayList.AddRange(m_Config.m_Overlays); if (m_Config.m_ShowGuidesInPreview) { m_GuidesOverlay = new ScreenshotOverlay(true, m_Config.m_GuideCanvas); m_PreviewOverlayList.Add(m_GuidesOverlay); } m_ScreenshotTaker.ApplySettings(GetActiveCameras(), m_PreviewOverlayList, m_Config.m_CaptureMode, m_Config.m_CaptureActiveUICanvas); }
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))); }
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 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); } }