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

Publishing command in VContainer root lifetimescope and receive in child lifetimescope #68

Open
astromanrx opened this issue Aug 27, 2024 · 0 comments

Comments

@astromanrx
Copy link

I have a root lifetimescope in VContainer , which container my NetworkManager object, I have child lifetimescopes that manage scene specific objects injection.
I have registered NetworkManager in root lifetimescope, I receive this error
"VContainerException: Failed to resolve GameEntryPoint : Failed to resolve NetworkManager : No such registration of type: VitalRouter.ICommandPublisher
VContainer.Internal.ReflectionInjector.CreateInstance (VContainer.IObjectResolver resolver, System.Collections.Generic.IReadOnlyList`1[T] parameters) (at"

Here's the content of my root lifetimescope:

using VContainer;
using VContainer.Unity;

public class BootstrapLifetimeScope : LifetimeScope
{        
    protected override void Configure(IContainerBuilder builder)
    {
        builder.Register<NetworkManager>(Lifetime.Singleton);               
        builder.RegisterEntryPoint<GameEntryPoint>();                         
    }
}

And here's my mainmenu scene lifetimescope object:

using UnityEngine;
using VContainer;
using VContainer.Unity;
using VitalRouter.VContainer;

public class MainmenuLifeScope : LifetimeScope
{
    [SerializeField]
    private ShopItemsCollection _shopItemsCollection;

    [SerializeField]
    private GameSettings _gameSettings;
        

    protected override void Configure(IContainerBuilder builder)
    {        
        builder.RegisterComponentInHierarchy<MainMenuController>();
        builder.RegisterComponentInHierarchy<HeroLook>();
        builder.RegisterComponentInHierarchy<CharacterPreview>();
        builder.RegisterVitalRouter(router=>{
            router.Map<MainMenuEvents>();
        });   
        builder.RegisterInstance(_shopItemsCollection);
        builder.RegisterInstance(_gameSettings);        
        builder.RegisterEntryPoint<GameEntryPoint>();
    }
}
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