@@ -284,7 +284,6 @@ public static event Action<PlayModeStateChange> playModeStateChanged
284284 internal static Func < bool > doPressedKeysTriggerAnyShortcut ;
285285
286286 public static event Action < bool > focusChanged ;
287- public static bool isFocused { get ; private set ; }
288287
289288 // Windows were reordered
290289 internal static CallbackFunction windowsReordered ;
@@ -477,8 +476,12 @@ static void Internal_PauseStateChanged(PauseState state)
477476 playmodeStateChanged ? . Invoke ( ) ;
478477 #pragma warning restore 618
479478
479+ using var scope = new ProgressScope ( $ "PauseStateChanged Callback", "" , forceShow : true ) ;
480480 foreach ( var evt in m_PauseStateChangedEvent )
481+ {
482+ scope . SetText ( $ "{ evt . Method ? . DeclaringType ? . FullName } .{ evt . Method ? . Name } ", true ) ;
481483 evt ( state ) ;
484+ }
482485 }
483486
484487 [ RequiredByNativeCode ]
@@ -487,9 +490,28 @@ static void Internal_PlayModeStateChanged(PlayModeStateChange state)
487490 #pragma warning disable 618
488491 playmodeStateChanged ? . Invoke ( ) ;
489492 #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 ) ;
491510 foreach ( var evt in m_PlayModeStateChangedEvent )
511+ {
512+ scope . SetText ( $ "{ evt . Method ? . DeclaringType ? . FullName } .{ evt . Method ? . Name } ", true ) ;
492513 evt ( state ) ;
514+ }
493515 }
494516
495517 [ RequiredByNativeCode ]
0 commit comments