Skip to content

How to inject one interface into multiple instances of a Component? #796

@ReKylee

Description

@ReKylee

I have an IPoolService for my Object Pooling interface, and I'm trying to inject it into every FireballWeapon or IWeapon in my scene.
I'm using this in my GameLifetimeScope.cs:

...
// Pooling System
builder.RegisterComponentInHierarchy<PoolManager>().As<IPoolService>();
// Weapons
builder.RegisterComponentInHierarchy<FireballWeapon>();
...

Yet it only injects into the first FireballWeapon MonoBehavior it finds.
How can solve this ??? I obviously want to avoid assigning the pools in the inspector.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions