Ejemplo n.º 1
0
        public override void BeginRecording(RecordingSession session)
        {
            int screenWidth  = Screen.width;
            int screenHeight = Screen.height;

#if UNITY_EDITOR
            switch (scSettings.m_OutputSize)
            {
            case EImageDimension.Window:
            {
                GameViewSize.GetGameRenderSize(out screenWidth, out screenHeight);
                outputWidth  = screenWidth;
                outputHeight = screenHeight;

                if (scSettings.m_ForceEvenSize)
                {
                    outputWidth  = (outputWidth + 1) & ~1;
                    outputHeight = (outputHeight + 1) & ~1;
                }
                break;
            }

            default:
            {
                outputHeight = (int)scSettings.m_OutputSize;
                outputWidth  = (int)(outputHeight * AspectRatioHelper.GetRealAR(scSettings.m_AspectRatio));

                if (scSettings.m_ForceEvenSize)
                {
                    outputWidth  = (outputWidth + 1) & ~1;
                    outputHeight = (outputHeight + 1) & ~1;
                }

                break;
            }
            }

            int w, h;
            GameViewSize.GetGameRenderSize(out w, out h);
            if (w != outputWidth || h != outputHeight)
            {
                var size = GameViewSize.SetCustomSize(outputWidth, outputHeight) ?? GameViewSize.AddSize(outputWidth, outputHeight);
                if (GameViewSize.m_ModifiedResolutionCount == 0)
                {
                    GameViewSize.BackupCurrentSize();
                }
                else
                {
                    if (size != GameViewSize.currentSize)
                    {
                        Debug.LogError("Requestion a resultion change while a recorder's input has already requested one! Undefined behaviour.");
                    }
                }
                GameViewSize.m_ModifiedResolutionCount++;
                m_ModifiedResolution = true;
                GameViewSize.SelectSize(size);
            }
#endif
        }
Ejemplo n.º 2
0
        public override void BeginRecording(RecordingSession session)
        {
            if (cbSettings.m_FlipFinalOutput)
            {
                m_VFlipper = new TextureFlipper();
            }

            m_quad = CreateFullscreenQuad();
            switch (cbSettings.source)
            {
            case EImageSource.ActiveCameras:
            case EImageSource.MainCamera:
            case EImageSource.TaggedCamera:
            {
                int screenWidth  = Screen.width;
                int screenHeight = Screen.height;
#if UNITY_EDITOR
                switch (cbSettings.m_OutputSize)
                {
                case EImageDimension.Window:
                {
                    GameViewSize.GetGameRenderSize(out screenWidth, out screenHeight);
                    outputWidth  = screenWidth;
                    outputHeight = screenHeight;

                    if (cbSettings.m_ForceEvenSize)
                    {
                        outputWidth  = (outputWidth + 1) & ~1;
                        outputHeight = (outputHeight + 1) & ~1;
                    }

                    break;
                }

                default:
                {
                    outputHeight = (int)cbSettings.m_OutputSize;
                    outputWidth  = (int)(outputHeight * AspectRatioHelper.GetRealAR(cbSettings.m_AspectRatio));

                    if (cbSettings.m_ForceEvenSize)
                    {
                        outputWidth  = (outputWidth + 1) & ~1;
                        outputHeight = (outputHeight + 1) & ~1;
                    }

                    var size = GameViewSize.SetCustomSize(outputWidth, outputHeight);
                    if (size == null)
                    {
                        size = GameViewSize.AddSize(outputWidth, outputHeight);
                    }

                    if (GameViewSize.m_ModifiedResolutionCount == 0)
                    {
                        GameViewSize.BackupCurrentSize();
                    }
                    else
                    {
                        if (size != GameViewSize.currentSize)
                        {
                            Debug.LogError("Requestion a resultion change while a recorder's input has already requested one! Undefined behaviour.");
                        }
                    }
                    GameViewSize.m_ModifiedResolutionCount++;
                    m_ModifiedResolution = true;
                    GameViewSize.SelectSize(size);
                    break;
                }
                }
#endif
                break;
            }

            default:
                throw new ArgumentOutOfRangeException();
            }

            if (cbSettings.m_CaptureUI)
            {
                var uiGO = new GameObject();
                uiGO.name             = "UICamera";
                uiGO.transform.parent = session.m_RecorderGO.transform;

                m_UICamera               = uiGO.AddComponent <Camera>();
                m_UICamera.cullingMask   = 1 << 5;
                m_UICamera.clearFlags    = CameraClearFlags.Depth;
                m_UICamera.renderingPath = RenderingPath.DeferredShading;
                m_UICamera.targetTexture = outputRT;
                m_UICamera.enabled       = false;
            }
        }