Skip to content
This repository was archived by the owner on Feb 16, 2024. It is now read-only.

Commit 048c12e

Browse files
committed
fix ScenePlaybackDetector.IsPlaying is still false when disable Domain Reloading
1 parent 284d5c5 commit 048c12e

2 files changed

Lines changed: 31 additions & 1 deletion

File tree

Assets/Plugins/UniRx/Scripts/UnityEngineBridge/MainThreadDispatcher.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff 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;

Assets/Plugins/UniRx/Scripts/UnityEngineBridge/ScenePlaybackDetector.cs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)