@@ -221,18 +221,18 @@ public void Start(Action finishedAction)
221221
222222 // Debug.Log("Called start for : " + sceneName);
223223
224- PerformanceTest . instance . StartCoroutine ( ProcessTest ( ) ) ;
224+ ProcessTestAsync ( ) ;
225225 }
226226 public void SetFinishedAction ( Action finishedAction ) { _finishedAction = finishedAction ; }
227227
228- IEnumerator ProcessTest ( )
228+ async Awaitable ProcessTestAsync ( )
229229 {
230230 if ( status == TestStageStatus . Waiting )
231231 {
232- yield return LoadAndInit ( ) ;
233- yield return new WaitForSeconds ( PerformanceTest . instance . _waitTime ) ;
234- yield return RunTest ( ) ;
235- yield return End ( ) ;
232+ await LoadAndInitAsync ( ) ;
233+ await Awaitable . WaitForSecondsAsync ( PerformanceTest . instance . _waitTime ) ;
234+ await RunTestAsync ( ) ;
235+ await EndAsync ( ) ;
236236 }
237237
238238 if ( _finishedAction != null )
@@ -242,21 +242,18 @@ IEnumerator ProcessTest()
242242 }
243243 }
244244
245- IEnumerator LoadAndInit ( )
245+ async Awaitable LoadAndInitAsync ( )
246246 {
247247 status = TestStageStatus . Warming ;
248248 _cancelButton . text = "Stop" ;
249249
250250
251251 // Debug.Log($"Load Scene {sceneName}");
252252
253- SceneManager . sceneLoaded += SceneLoadCallback ;
254- SceneManager . LoadSceneAsync ( sceneName , LoadSceneMode . Single ) ;
253+ await SceneManager . LoadSceneAsync ( sceneName , LoadSceneMode . Single ) ;
255254
256- // Wait for scene to be loaded
257- yield return new WaitUntil ( HasSceneLoaded ) ;
258-
259- yield return null ;
255+ await Awaitable . EndOfFrameAsync ( ) ;
256+
260257 PerformanceTest . instance . RefreshEventSystem ( ) ;
261258
262259 var directors = Resources . FindObjectsOfTypeAll < PlayableDirector > ( ) ;
@@ -309,25 +306,13 @@ IEnumerator LoadAndInit()
309306 _minFrameData = new FrameData ( Mathf . Infinity ) ;
310307 }
311308
312- private bool sceneLoaded = false ;
313- private bool HasSceneLoaded ( )
314- {
315- return sceneLoaded ;
316- }
317-
318- void SceneLoadCallback ( Scene scene , LoadSceneMode loadSceneMode )
319- {
320- // Debug.Log($"Scene {scene.name} has loaded.");
321-
322- SceneManager . SetActiveScene ( scene ) ;
323- sceneLoaded = true ;
324- SceneManager . sceneLoaded -= SceneLoadCallback ;
325- }
326309
327- IEnumerator RunTest ( )
310+ async Awaitable RunTestAsync ( )
328311 {
329312 if ( status != TestStageStatus . Warming )
330- yield break ;
313+ {
314+ return ;
315+ }
331316
332317 // Debug.Log("Start running test.");
333318
@@ -369,21 +354,25 @@ IEnumerator RunTest()
369354 _progressBarVe . style . width = P ( timerLineAdvancement ) ;
370355
371356 if ( noIntermediateTime )
372- yield return null ;
357+ await Awaitable . EndOfFrameAsync ( ) ;
373358 else
374- yield return new WaitForSeconds ( _intermediateCaptureTime ) ;
359+ await Awaitable . WaitForSecondsAsync ( _intermediateCaptureTime ) ;
375360 }
376361 }
377362
378- IEnumerator End ( )
363+ async Awaitable EndAsync ( )
379364 {
380365 _cancelButton . style . opacity = 0 ;
381366 _cancelButton . clicked -= Cancel ;
382367
383368 if ( status == TestStageStatus . Running )
369+ {
384370 status = TestStageStatus . Finished ;
371+ }
385372 else if ( status != TestStageStatus . Stopped )
386- yield break ;
373+ {
374+ return ;
375+ }
387376
388377 _progressContainerVE . style . opacity = 0f ;
389378 // Debug.Log($"Test {sceneName} finished and captured {_frameDatas.Count} frames timings");
@@ -408,7 +397,7 @@ IEnumerator End()
408397
409398 WriteCSV ( ) ;
410399
411- yield return null ;
400+ await Awaitable . EndOfFrameAsync ( ) ;
412401 }
413402
414403 void Cancel ( )
0 commit comments