@@ -136,7 +136,9 @@ public float EstimatedMemoryUse
136136 int m_MaxFrameCount ;
137137 float m_Time ;
138138 float m_TimePerFrame ;
139- Queue < RenderTexture > m_Frames ;
139+ float m_AbsoluteTime ;
140+ float m_LastTime ;
141+ Queue < RenderTexture > m_Frames ;
140142 RenderTexture m_RecycledRenderTexture ;
141143 ReflectionUtils < Recorder > m_ReflectionUtils ;
142144
@@ -215,7 +217,9 @@ public void Record()
215217 RenderPipelineManager . endContextRendering += OnEndCameraRendering ;
216218
217219 State = RecorderState . Recording ;
218- }
220+ m_Time = 0f ;
221+ m_AbsoluteTime = 0f ;
222+ }
219223
220224 /// <summary>
221225 /// Clears all saved frames from memory and starts fresh.
@@ -319,10 +323,22 @@ void OnRenderImage(RenderTexture source, RenderTexture destination)
319323 return ;
320324 }
321325
322- m_Time += Time . unscaledDeltaTime ;
323- if ( m_Time >= m_TimePerFrame )
324- {
325- m_Time -= m_TimePerFrame ;
326+ // Fixed invalid use of Time.unscaledDeltaTime.
327+ // from: https://github.com/Chman/Moments/pull/12/
328+ if ( m_LastTime == 0 )
329+ {
330+ m_Time += Time . unscaledDeltaTime ;
331+ m_LastTime = Time . time ;
332+ }
333+
334+ float deltaTime = Time . time - m_LastTime ;
335+ m_LastTime = Time . time ;
336+ m_Time += deltaTime ;
337+
338+ if ( m_Time >= m_TimePerFrame )
339+ {
340+ m_AbsoluteTime += m_TimePerFrame ;
341+ m_Time -= m_TimePerFrame ;
326342
327343 // Frame data
328344 RenderTexture rt = GetRecycledTexture ( ) ;
0 commit comments