Skip to content

Commit

Permalink
Merge pull request #650 from hadashiA/ku/fix-root-in-editor
Browse files Browse the repository at this point in the history
Fix a bug that LifetimeScope configure twice at editor
  • Loading branch information
hadashiA authored Mar 26, 2024
2 parents d64a49a + 6107ec1 commit 5bea225
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
Expand Up @@ -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()
Expand Down

0 comments on commit 5bea225

Please sign in to comment.