public static Texture2D GetOrCreateTexture(ScreenshotResolution resolution, ColorFormat colorFormat, bool noScale = false)
        {
            // Compute real dimensions
            int width  = noScale ? resolution.m_Width : resolution.ComputeTargetWidth();
            int height = noScale ? resolution.m_Height : resolution.ComputeTargetHeight();

            // Init the texture
            GetOrCreateTexture(ref resolution.m_Texture, width, height, colorFormat);

            return(resolution.m_Texture);
        }
        RenderTexture GetOrCreateRenderTexture(ScreenshotResolution resolution, int antiAliasing = 0, int depth = 32)
        {
            // Compute real resolutions
            int width  = resolution.ComputeTargetWidth();
            int height = resolution.ComputeTargetHeight();

            // Get from cache
            RenderTexture rt = null;

            if (m_RenderTextureCache.ContainsKey(resolution))
            {
                rt = m_RenderTextureCache[resolution];
            }
            // Create render texture if needed
            GetOrCreateRenderTexture(ref rt, width, height, antiAliasing, depth);
            // Save to cache
            m_RenderTextureCache[resolution] = rt;

            return(rt);
        }
예제 #3
0
        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;
        }