Skip to content

Commit

Permalink
Merge pull request #497 from voreshmag/feature/root-lifetime-scope-pa…
Browse files Browse the repository at this point in the history
…renting-fix

Root parenting fix
  • Loading branch information
hadashiA committed Apr 15, 2023
2 parents 0a1e11b + ea5bc14 commit 341a857
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion VContainer/Assets/VContainer/Runtime/Unity/LifetimeScope.cs
Expand Up @@ -209,7 +209,14 @@ public TScope CreateChild<TScope>(IInstaller installer = null)
{
var childGameObject = new GameObject("LifetimeScope (Child)");
childGameObject.SetActive(false);
childGameObject.transform.SetParent(transform, false);
if (IsRoot)
{
DontDestroyOnLoad(childGameObject);
}
else
{
childGameObject.transform.SetParent(transform, false);
}
var child = childGameObject.AddComponent<TScope>();
if (installer != null)
{
Expand Down

1 comment on commit 341a857

@vercel
Copy link

@vercel vercel bot commented on 341a857 Apr 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.