Skip to content

Commit f5c9f45

Browse files
committed
add PrefabDirtyScope when instantiate RootLifetimeScope
1 parent 0093a45 commit f5c9f45

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

VContainer/Assets/VContainer/Runtime/Unity/VContainerSettings.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,18 @@ public LifetimeScope GetOrCreateRootLifetimeScopeInstance()
7171
{
7272
if (RootLifetimeScope != null && rootLifetimeScopeInstance == null)
7373
{
74-
var activeBefore = RootLifetimeScope.gameObject.activeSelf;
75-
RootLifetimeScope.gameObject.SetActive(false);
74+
using (new ObjectResolverUnityExtensions.PrefabDirtyScope(RootLifetimeScope.gameObject))
75+
{
76+
var activeBefore = RootLifetimeScope.gameObject.activeSelf;
77+
RootLifetimeScope.gameObject.SetActive(false);
7678

77-
rootLifetimeScopeInstance = Instantiate(RootLifetimeScope);
78-
SetName(rootLifetimeScopeInstance, RootLifetimeScope);
79-
DontDestroyOnLoad(rootLifetimeScopeInstance);
80-
rootLifetimeScopeInstance.gameObject.SetActive(true);
79+
rootLifetimeScopeInstance = Instantiate(RootLifetimeScope);
80+
SetName(rootLifetimeScopeInstance, RootLifetimeScope);
81+
DontDestroyOnLoad(rootLifetimeScopeInstance);
82+
rootLifetimeScopeInstance.gameObject.SetActive(true);
8183

82-
RootLifetimeScope.gameObject.SetActive(activeBefore);
84+
RootLifetimeScope.gameObject.SetActive(activeBefore);
85+
}
8386
}
8487
return rootLifetimeScopeInstance;
8588
}

0 commit comments

Comments
 (0)