This repository was archived by the owner on Feb 16, 2024. It is now read-only.
File tree Expand file tree Collapse file tree
Assets/Plugins/UniRx/Scripts/UnityEngineBridge Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -669,6 +669,12 @@ public static IObservable<bool> OnApplicationPauseAsObservable()
669669
670670 Subject < Unit > onApplicationQuit ;
671671
672+ [ RuntimeInitializeOnLoadMethod ( RuntimeInitializeLoadType . AfterAssembliesLoaded ) ]
673+ public static void OnRuntimeInitializeOnLoadMethod ( )
674+ {
675+ isQuitting = false ;
676+ }
677+
672678 void OnApplicationQuit ( )
673679 {
674680 isQuitting = true ;
Original file line number Diff line number Diff line change @@ -38,6 +38,15 @@ public static bool IsPlaying
3838 }
3939 }
4040
41+ [ RuntimeInitializeOnLoadMethod ( RuntimeInitializeLoadType . AfterAssembliesLoaded ) ]
42+ public static void OnRuntimeInitializeOnLoadMethod ( )
43+ {
44+ if ( AboutToStartScene )
45+ {
46+ IsPlaying = true ;
47+ }
48+ }
49+
4150 // This callback is notified after scripts have been reloaded.
4251 [ DidReloadScripts ]
4352 public static void OnDidReloadScripts ( )
@@ -54,9 +63,23 @@ static ScenePlaybackDetector()
5463 {
5564#if UNITY_2017_2_OR_NEWER
5665 EditorApplication . playModeStateChanged += e =>
66+ {
67+ if ( e == PlayModeStateChange . ExitingEditMode )
68+ {
69+ AboutToStartScene = true ;
70+ }
71+ else
72+ {
73+ AboutToStartScene = false ;
74+ }
75+
76+ if ( e == PlayModeStateChange . ExitingPlayMode )
77+ {
78+ IsPlaying = false ;
79+ }
80+ } ;
5781#else
5882 EditorApplication . playmodeStateChanged += ( ) =>
59- #endif
6083 {
6184 // Before scene start: isPlayingOrWillChangePlaymode = false; isPlaying = false
6285 // Pressed Playback button: isPlayingOrWillChangePlaymode = true; isPlaying = false
@@ -77,6 +100,7 @@ static ScenePlaybackDetector()
77100 IsPlaying = false ;
78101 }
79102 } ;
103+ #endif
80104 }
81105 }
82106}
You can’t perform that action at this time.
0 commit comments