From 4e297edbce0c59b85f985f0d39d8ab25b5932f11 Mon Sep 17 00:00:00 2001 From: Artur Kovacs Date: Wed, 23 Oct 2019 10:32:10 +0200 Subject: [PATCH 1/2] Only limit framerate while recording --- .../Assets/UTJ/FrameCapturer/Scripts/RecorderBase.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/FrameCapturer/Assets/UTJ/FrameCapturer/Scripts/RecorderBase.cs b/FrameCapturer/Assets/UTJ/FrameCapturer/Scripts/RecorderBase.cs index eacaf1e9..5e7636b5 100644 --- a/FrameCapturer/Assets/UTJ/FrameCapturer/Scripts/RecorderBase.cs +++ b/FrameCapturer/Assets/UTJ/FrameCapturer/Scripts/RecorderBase.cs @@ -209,7 +209,7 @@ protected IEnumerator Wait() float wt = (1.0f / m_targetFramerate) * (Time.renderedFrameCount - m_initialFrame); while (Time.realtimeSinceStartup - m_initialRealTime < wt) { - System.Threading.Thread.Sleep(1); + System.Threading.Thread.Yield(); } } @@ -285,9 +285,12 @@ protected virtual void Update() { } - if(m_framerateMode == FrameRateMode.Constant && m_fixDeltaTime && m_waitDeltaTime) + if (m_recording) { - StartCoroutine(Wait()); + if (m_framerateMode == FrameRateMode.Constant && m_fixDeltaTime && m_waitDeltaTime) + { + StartCoroutine(Wait()); + } } } } From 80587828a242cc74057dc25bbcbf9c70b82b850d Mon Sep 17 00:00:00 2001 From: Artur Kovacs Date: Wed, 23 Oct 2019 11:06:39 +0200 Subject: [PATCH 2/2] Reverted back to the less intrusive function --- FrameCapturer/Assets/UTJ/FrameCapturer/Scripts/RecorderBase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FrameCapturer/Assets/UTJ/FrameCapturer/Scripts/RecorderBase.cs b/FrameCapturer/Assets/UTJ/FrameCapturer/Scripts/RecorderBase.cs index 5e7636b5..38b69956 100644 --- a/FrameCapturer/Assets/UTJ/FrameCapturer/Scripts/RecorderBase.cs +++ b/FrameCapturer/Assets/UTJ/FrameCapturer/Scripts/RecorderBase.cs @@ -209,7 +209,7 @@ protected IEnumerator Wait() float wt = (1.0f / m_targetFramerate) * (Time.renderedFrameCount - m_initialFrame); while (Time.realtimeSinceStartup - m_initialRealTime < wt) { - System.Threading.Thread.Yield(); + System.Threading.Thread.Sleep(1); } }