Skip to content

Commit

Permalink
Fix a bug that LifetimeScope configure twice at editor
Browse files Browse the repository at this point in the history
hadashiA committed Mar 26, 2024
1 parent d64a49a commit 6107ec1
Showing 1 changed file with 0 additions and 18 deletions.
18 changes: 0 additions & 18 deletions VContainer/Assets/VContainer/Runtime/Unity/VContainerSettings.cs
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 6107ec1

Please sign in to comment.