From 2163f58c229847282820762762b8b72c91b342c6 Mon Sep 17 00:00:00 2001 From: hadashi Date: Mon, 15 Feb 2021 06:06:21 +0900 Subject: [PATCH] Fix a bug that RootLIfetimeScope missing when Domain reloading is disabled. --- .../Assets/VContainer/Runtime/Unity/LifetimeScope.cs | 11 ----------- .../VContainer/Runtime/Unity/VContainerSettings.cs | 3 +-- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/VContainer/Assets/VContainer/Runtime/Unity/LifetimeScope.cs b/VContainer/Assets/VContainer/Runtime/Unity/LifetimeScope.cs index 078fbcde..830de8c2 100644 --- a/VContainer/Assets/VContainer/Runtime/Unity/LifetimeScope.cs +++ b/VContainer/Assets/VContainer/Runtime/Unity/LifetimeScope.cs @@ -273,17 +273,6 @@ LifetimeScope GetRuntimeParent() if (VContainerSettings.Instance is VContainerSettings settings) { var rootLifetimeScope = settings.RootLifetimeScope; -#if UNITY_EDITOR - var disableDomainReloading = UnityEditor.EditorSettings.enterPlayModeOptionsEnabled && - (UnityEditor.EditorSettings.enterPlayModeOptions & - UnityEditor.EnterPlayModeOptions.DisableDomainReload) > 0; - if (rootLifetimeScope == null && disableDomainReloading) - { - var path = UnityEditor.AssetDatabase.GetAssetPath(rootLifetimeScope); - if (!string.IsNullOrEmpty(path)) - UnityEngine.Debug.LogError($"VContainerSettings.RootLifetimeScope is missing : {path}. Please try to re-compile C# scripts just once."); - } -#endif if (rootLifetimeScope != null) { if (rootLifetimeScope.Container == null) diff --git a/VContainer/Assets/VContainer/Runtime/Unity/VContainerSettings.cs b/VContainer/Assets/VContainer/Runtime/Unity/VContainerSettings.cs index a77dafc2..14541107 100644 --- a/VContainer/Assets/VContainer/Runtime/Unity/VContainerSettings.cs +++ b/VContainer/Assets/VContainer/Runtime/Unity/VContainerSettings.cs @@ -1,7 +1,6 @@ using System; using System.Linq; using UnityEngine; -using VContainer.Unity; namespace VContainer.Unity { @@ -45,7 +44,7 @@ public static void CreateAsset() UnityEditor.PlayerSettings.SetPreloadedAssets(preloadedAssets.ToArray()); } - [UnityEditor.InitializeOnLoadMethod] + [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)] public static void LoadInstanceFromAssetDatabase() { var guids = UnityEditor.AssetDatabase.FindAssets("t:VContainerSettings");