@@ -221,18 +221,18 @@ public void Start(Action finishedAction)
221
221
222
222
// Debug.Log("Called start for : " + sceneName);
223
223
224
- PerformanceTest . instance . StartCoroutine ( ProcessTest ( ) ) ;
224
+ ProcessTestAsync ( ) ;
225
225
}
226
226
public void SetFinishedAction ( Action finishedAction ) { _finishedAction = finishedAction ; }
227
227
228
- IEnumerator ProcessTest ( )
228
+ async Awaitable ProcessTestAsync ( )
229
229
{
230
230
if ( status == TestStageStatus . Waiting )
231
231
{
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 ( ) ;
236
236
}
237
237
238
238
if ( _finishedAction != null )
@@ -242,21 +242,18 @@ IEnumerator ProcessTest()
242
242
}
243
243
}
244
244
245
- IEnumerator LoadAndInit ( )
245
+ async Awaitable LoadAndInitAsync ( )
246
246
{
247
247
status = TestStageStatus . Warming ;
248
248
_cancelButton . text = "Stop" ;
249
249
250
250
251
251
// Debug.Log($"Load Scene {sceneName}");
252
252
253
- SceneManager . sceneLoaded += SceneLoadCallback ;
254
- SceneManager . LoadSceneAsync ( sceneName , LoadSceneMode . Single ) ;
253
+ await SceneManager . LoadSceneAsync ( sceneName , LoadSceneMode . Single ) ;
255
254
256
- // Wait for scene to be loaded
257
- yield return new WaitUntil ( HasSceneLoaded ) ;
258
-
259
- yield return null ;
255
+ await Awaitable . EndOfFrameAsync ( ) ;
256
+
260
257
PerformanceTest . instance . RefreshEventSystem ( ) ;
261
258
262
259
var directors = Resources . FindObjectsOfTypeAll < PlayableDirector > ( ) ;
@@ -309,25 +306,13 @@ IEnumerator LoadAndInit()
309
306
_minFrameData = new FrameData ( Mathf . Infinity ) ;
310
307
}
311
308
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
- }
326
309
327
- IEnumerator RunTest ( )
310
+ async Awaitable RunTestAsync ( )
328
311
{
329
312
if ( status != TestStageStatus . Warming )
330
- yield break ;
313
+ {
314
+ return ;
315
+ }
331
316
332
317
// Debug.Log("Start running test.");
333
318
@@ -369,21 +354,25 @@ IEnumerator RunTest()
369
354
_progressBarVe . style . width = P ( timerLineAdvancement ) ;
370
355
371
356
if ( noIntermediateTime )
372
- yield return null ;
357
+ await Awaitable . EndOfFrameAsync ( ) ;
373
358
else
374
- yield return new WaitForSeconds ( _intermediateCaptureTime ) ;
359
+ await Awaitable . WaitForSecondsAsync ( _intermediateCaptureTime ) ;
375
360
}
376
361
}
377
362
378
- IEnumerator End ( )
363
+ async Awaitable EndAsync ( )
379
364
{
380
365
_cancelButton . style . opacity = 0 ;
381
366
_cancelButton . clicked -= Cancel ;
382
367
383
368
if ( status == TestStageStatus . Running )
369
+ {
384
370
status = TestStageStatus . Finished ;
371
+ }
385
372
else if ( status != TestStageStatus . Stopped )
386
- yield break ;
373
+ {
374
+ return ;
375
+ }
387
376
388
377
_progressContainerVE . style . opacity = 0f ;
389
378
// Debug.Log($"Test {sceneName} finished and captured {_frameDatas.Count} frames timings");
@@ -408,7 +397,7 @@ IEnumerator End()
408
397
409
398
WriteCSV ( ) ;
410
399
411
- yield return null ;
400
+ await Awaitable . EndOfFrameAsync ( ) ;
412
401
}
413
402
414
403
void Cancel ( )
0 commit comments