Merge pull request #52 from Elringus/feature/support-disable-domain-reload

Support disable domain reload (fast enter play mode)
master
Yoshifumi Kawai 2020-04-15 21:30:22 +09:00 committed by GitHub
commit de3d491375
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 2 deletions

View File

@ -96,8 +96,10 @@ namespace UniRx.Async
#endif
};
var dest = new PlayerLoopSystem[loopSystem.subSystemList.Length + 2];
Array.Copy(loopSystem.subSystemList, 0, dest, 2, loopSystem.subSystemList.Length);
var source = loopSystem.subSystemList // Remove items from previous initializations.
.Where(ls => ls.type != loopRunnerYieldType && ls.type != loopRunnerType).ToArray();
var dest = new PlayerLoopSystem[source.Length + 2];
Array.Copy(source, 0, dest, 2, source.Length);
dest[0] = yieldLoop;
dest[1] = runnerLoop;
return dest;
@ -110,7 +112,15 @@ namespace UniRx.Async
unitySynchronizationContetext = SynchronizationContext.Current;
mainThreadId = Thread.CurrentThread.ManagedThreadId;
#if UNITY_EDITOR && UNITY_2019_3_OR_NEWER
// When domain reload is disabled, re-initialization is required when entering play mode;
// otherwise, pending tasks will leak between play mode sessions.
var domainReloadDisabled = UnityEditor.EditorSettings.enterPlayModeOptionsEnabled &&
UnityEditor.EditorSettings.enterPlayModeOptions.HasFlag(UnityEditor.EnterPlayModeOptions.DisableDomainReload);
if (!domainReloadDisabled && runners != null) return;
#else
if (runners != null) return; // already initialized
#endif
var playerLoop =
#if UNITY_2019_3_OR_NEWER