Skip to content

How can I Instantiate a Gameobject at runtime like zenject's sub container #473

Closed Answered by SimonNordon4
cowbear6598 asked this question in Q&A
Discussion options

You must be logged in to vote
[SerializedField]
private CharacterView characterPrefab;

builder.RegisterFactory<CharacterMoveHandler >(container =>
{
    return () =>
    {
        var CharacterView = container.Instantiate(characterPrefab);
        var moveHandler = new MoveHandler(CharacterView);
    };
}, Lifetime.Scoped);

Something like this should work.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@cowbear6598
Comment options

Answer selected by cowbear6598
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants