VContainer icon indicating copy to clipboard operation
VContainer copied to clipboard

Can't add unmanaged systems via NewWorldBuilder

Open Hlibix opened this issue 9 months ago • 1 comments

I want to use World Builder as a declarative list of all systems. Adding managed systems causes no problems whether it has injection or not. Unmanaged systems, however, are so far impossible to register via the builder:

  • AddUnmanaged requires an instance of the system to be passed
  • Adding the system manually via builder.RegisterUnmanagedSystemIntoWorld yields to having an exception of VContainerException: Type does not found injectable constructor
    • Adding an [Inject]-marked method does not solve an issue, even if it has some registered dependency as an unused argument
    • Also, it is impossible to add a constructor to a unmanaged system, since it requires to initialize the technical fields

So, it would be great to have an opportunity to register unmanaged systems into a new world without having to pass an instance and without needing to inject anything into them, smth like:

builder.UseNewWorld("World", Lifetime.Scoped, worldBuilder =>
{
    worldBuilder.AddUnmanaged<MyUnmanagedSystem>();
}

Hlibix avatar Mar 15 '25 21:03 Hlibix

HI, You can refer to the following Test file. https://github.com/hadashiA/VContainer/blob/master/VContainer/Assets/Tests/Unity/EcsTest.cs

stenyin avatar Apr 08 '25 16:04 stenyin