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

Control the find scope of RegisterComponentInHierarchy. #116

Merged
merged 4 commits into from
Feb 10, 2021

Conversation

hadashiA
Copy link
Owner

@hadashiA hadashiA commented Feb 8, 2021

RegisterComponentInHierarchy with finding under specific parent transform

builder.RegisterComponentInHIerarchy<ComponentA>()
    .UnderTransform(parent); 

Add UseComponents with specific parent transform

builder.UseComponents(parentTransform, components =>
{
    // GetComponentInChildren under `parentTransform`
    components.AddInHierarchy<YourBehaviour>();

    // Instantiate under `parentTransform`
    components.AddFromNewPrefab(prefab, Lifetime.Scoped);
    components.AddOnNewGameObject<YourBehaviour>(Lifetime.Scoped, "name");
})

This is the same as:

builder.RegisterComponentInHierarchy<YourBehaviour>()
    .UnderTransform(parentTransform);

builder.RegisterComponentFromNewPrefab(prefab, Lifetime.Scoped)
    .UnderTransform(parentTransform);
builder.RegisterComponentOnNewGameObject<YourBehaviour>(Lifetime.Scoped, "name");
    .UnderTransform(parentTransform);

@vercel
Copy link

vercel bot commented Feb 8, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/hadashia/vcontainer/692o5qobe
✅ Preview: https://vcontainer-git-ku-scoped-hierarchy.hadashia.vercel.app

@hadashiA hadashiA marked this pull request as ready for review February 10, 2021 03:44
@hadashiA hadashiA merged commit f2cb6a3 into master Feb 10, 2021
@hadashiA hadashiA deleted the ku/scoped-hierarchy branch February 10, 2021 08:49
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

Successfully merging this pull request may close these issues.

1 participant