Skip to content

Interfaces and FromComponentInNewPrefab #666

Open
@ut2496

Description

@ut2496

I recently shifted from Zenject v5.4 to Zenject 6+.
I understand that using AsSingle across multiple statements is not suitable anymore, I have been able to adapt the changes in most cases barring the following with interfaces.

I used the following way to install certain bindings while using v5.4

Container.Bind<IFoo>().To<Foo>().FromComponentInNewPrefab(Prefab).AsSingle();
Container.Bind<IBar>().To<Bar>().FromComponentInNewPrefab(Prefab).AsSingle();

This used to only create a single instance of Prefab. But in Zenject 6+ it creates a duplicate Prefab too. Switching the latter to AsCached doesn't work either.

Since Interfaces are binding to different ResultType I cant do something like this either:
Container.Bind<typeof(IFoo), typeof(IBar)>().To<Z>().FromComponentInNewPrefab(Prefab).AsSingle();

Is this the intended behavior now ? If Yes, then Is there a way now to get the same behavior as present in v5.4 ?

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