VitalRouter icon indicating copy to clipboard operation
VitalRouter copied to clipboard

Publishing command in VContainer root lifetimescope and receive in child lifetimescope

Open astromanrx opened this issue 1 year ago • 0 comments

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>();
    }
}

astromanrx avatar Aug 27 '24 22:08 astromanrx