From 6107ec134b80fb7e81c06a2d6ce56bbcac675a0f Mon Sep 17 00:00:00 2001 From: hadashiA Date: Tue, 26 Mar 2024 17:11:48 +0900 Subject: [PATCH] Fix a bug that LifetimeScope configure twice at editor --- .../Runtime/Unity/VContainerSettings.cs | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/VContainer/Assets/VContainer/Runtime/Unity/VContainerSettings.cs b/VContainer/Assets/VContainer/Runtime/Unity/VContainerSettings.cs index 5a2badf1..71bcf085 100644 --- a/VContainer/Assets/VContainer/Runtime/Unity/VContainerSettings.cs +++ b/VContainer/Assets/VContainer/Runtime/Unity/VContainerSettings.cs @@ -48,24 +48,6 @@ public static void CreateAsset() preloadedAssets.Add(newSettings); UnityEditor.PlayerSettings.SetPreloadedAssets(preloadedAssets.ToArray()); } - - public static void LoadInstanceFromPreloadAssets() - { - var preloadAsset = UnityEditor.PlayerSettings.GetPreloadedAssets().FirstOrDefault(x => x is VContainerSettings); - if (preloadAsset is VContainerSettings instance) - { - if (instance.RootLifetimeScope != null) - instance.RootLifetimeScope.DisposeCore(); - instance.OnEnable(); - } - } - - [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)] - static void RuntimeInitialize() - { - // For editor, we need to load the Preload asset manually. - LoadInstanceFromPreloadAssets(); - } #endif public LifetimeScope GetOrCreateRootLifetimeScopeInstance()