Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating a child scope from root scope does not parent the child scope game object to the root scope game object #739

Open
jonah1nine opened this issue Dec 28, 2024 · 0 comments

Comments

@jonah1nine
Copy link

When creating a childscope using

rootScope.CreateChild();

the child scope game object is not parented to the root scope game object.
However creating a child scope from prefab, parents the child scope game object to the root scope game object as expected.

rootScope.CreateChildFromPrefab(childScopePrefab);

Also if a non-root scope creates a child scope, it parents the child scope game object to parent scope game object as expected.

nonRootScope.CreateChild();

This is what I get when running the code below
Screenshot 2024-12-28 at 12 21 44

public class Test : MonoBehaviour
{
    [SerializeField] private ChildLifetimeScope childLifetimeScopePrefab;
    
    void Start()
    {
        var rootScope = LifetimeScope.Find<RootLifetimeScope>();
        var parentScope = LifetimeScope.Find<ParentLifetimeScope>();

        rootScope.CreateChild(childScopeName: "Child Lifetime Scope - Root");
        rootScope.CreateChildFromPrefab(childLifetimeScopePrefab);
        parentScope.CreateChild(childScopeName: "Child Lifetime Scope - Parent");
    }
}


public class RootLifetimeScope : LifetimeScope { }
public class ParentLifetimeScope : LifetimeScope { }

Also is setting the parent of a LifetimeScope in editor to the root scope makes that LifetimeScope game object parented to the root scope? Because that's not happening as well - as seen above.
Screenshot 2024-12-28 at 12 33 27

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant