Ejemplo n.º 1
0
        public override void BeginRecording(RecordingSession session)
        {
            outputWidth  = scSettings.outputWidth;
            outputHeight = scSettings.outputHeight;

            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.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.modifiedResolutionCount++;
                m_ModifiedResolution = true;
                GameViewSize.SelectSize(size);
            }

#if !UNITY_2019_1_OR_NEWER
            // Before 2019.1, we capture syncrhonously into a Texture2D, so we don't need to create
            // a RenderTexture that is used for reading asynchronously.
            return;
#else
            m_CaptureTexture = new RenderTexture(outputWidth, outputHeight, 0, RenderTextureFormat.ARGB32)
            {
                wrapMode = TextureWrapMode.Repeat
            };
            m_CaptureTexture.Create();

            if (scSettings.flipFinalOutput)
            {
                m_VFlipper = new TextureFlipper(false);
                m_VFlipper.Init(m_CaptureTexture);
                outputRT = m_VFlipper.workTexture;
            }
            else
            {
                outputRT = m_CaptureTexture;
            }
#endif
        }
Ejemplo n.º 2
0
        protected internal override void BeginRecording(RecordingSession session)
        {
            OutputWidth  = scSettings.OutputWidth;
            OutputHeight = scSettings.OutputHeight;

            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.modifiedResolutionCount == 0)
                {
                    GameViewSize.BackupCurrentSize();
                }
                else
                {
                    if (size != GameViewSize.currentSize)
                    {
                        Debug.LogError("Requesting a resolution change while a recorder's input has already requested one! Undefined behaviour.");
                    }
                }
                GameViewSize.modifiedResolutionCount++;
                m_ModifiedResolution = true;
                GameViewSize.SelectSize(size);
            }

            // Initialize the temporary texture for forcing opacity
            m_TempCaptureTextureOpaque = RenderTexture.GetTemporary(w, h);

#if !UNITY_2019_1_OR_NEWER
            // Before 2019.1, we capture synchronously into a Texture2D, so we don't need to create
            // a RenderTexture that is used for reading asynchronously.
            return;
#else
            m_CaptureTexture = new RenderTexture(OutputWidth, OutputHeight, 0, RenderTextureFormat.ARGB32)
            {
                wrapMode = TextureWrapMode.Repeat
            };
            m_CaptureTexture.Create();
            m_CaptureTexture.name = "GameViewInput_mCaptureTexture";

            var  movieRecorderSettings = session.settings as MovieRecorderSettings;
            bool needToFlip            = scSettings.FlipFinalOutput;
            if (movieRecorderSettings != null)
            {
                bool encoderAlreadyFlips = movieRecorderSettings.encodersRegistered[movieRecorderSettings.encoderSelected].PerformsVerticalFlip;
                needToFlip &= encoderAlreadyFlips;
            }

            if (needToFlip)
            {
                m_VFlipper = new TextureFlipper(false);
                m_VFlipper.Init(m_CaptureTexture);
                OutputRenderTexture = m_VFlipper.workTexture;
            }
            else
            {
                OutputRenderTexture = m_CaptureTexture;
            }
#endif
        }