@@ -284,7 +284,6 @@ public static event Action<PlayModeStateChange> playModeStateChanged
284
284
internal static Func < bool > doPressedKeysTriggerAnyShortcut ;
285
285
286
286
public static event Action < bool > focusChanged ;
287
- public static bool isFocused { get ; private set ; }
288
287
289
288
// Windows were reordered
290
289
internal static CallbackFunction windowsReordered ;
@@ -477,8 +476,12 @@ static void Internal_PauseStateChanged(PauseState state)
477
476
playmodeStateChanged ? . Invoke ( ) ;
478
477
#pragma warning restore 618
479
478
479
+ using var scope = new ProgressScope ( $ "PauseStateChanged Callback", "" , forceShow : true ) ;
480
480
foreach ( var evt in m_PauseStateChangedEvent )
481
+ {
482
+ scope . SetText ( $ "{ evt . Method ? . DeclaringType ? . FullName } .{ evt . Method ? . Name } ", true ) ;
481
483
evt ( state ) ;
484
+ }
482
485
}
483
486
484
487
[ RequiredByNativeCode ]
@@ -487,9 +490,28 @@ static void Internal_PlayModeStateChanged(PlayModeStateChange state)
487
490
#pragma warning disable 618
488
491
playmodeStateChanged ? . Invoke ( ) ;
489
492
#pragma warning restore 618
490
-
493
+ if ( ! m_PlayModeStateChangedEvent . hasSubscribers ) return ;
494
+ var stateName = state . ToString ( ) ;
495
+
496
+ // Without this workaround, you will fail Editor.GameViewTests.Playmode_PlayUnfocused_IsUnfocused_WhenGameViewFocused
497
+ // You can still trigger UUM-74498 by showing a ProgressScope in EnteredPlayMode (including in usercode with EditorUtility.DisplayProgressBar)
498
+ // This is because a progress bar going away will cause the previously focused window to be refocused
499
+ // The underlying issue is being tracked in UUM-86918 and this workaround should be undone as part of the fix there
500
+ if ( PlayModeView . GetMainPlayModeView ( ) is GameView { enterPlayModeBehavior : PlayModeView . EnterPlayModeBehavior . PlayUnfocused }
501
+ && state == PlayModeStateChange . EnteredPlayMode )
502
+ {
503
+ foreach ( var evt in m_PlayModeStateChangedEvent )
504
+ {
505
+ evt ( state ) ;
506
+ }
507
+ return ;
508
+ }
509
+ using var scope = new ProgressScope ( $ "PlayModeStateChanged Callback ({ stateName } )", "" , forceShow : true ) ;
491
510
foreach ( var evt in m_PlayModeStateChangedEvent )
511
+ {
512
+ scope . SetText ( $ "{ evt . Method ? . DeclaringType ? . FullName } .{ evt . Method ? . Name } ", true ) ;
492
513
evt ( state ) ;
514
+ }
493
515
}
494
516
495
517
[ RequiredByNativeCode ]
0 commit comments