2D-Platformer/Assets/Scripts/Util/ZenjectExtensions.cs
2022-02-12 12:53:50 +02:00

20 lines
No EOL
478 B
C#

using Unity.Entities;
using Zenject;
namespace Util
{
public static class ZenjectExtensions
{
public static IfNotBoundBinder FromEcs<TContract>(this ConcreteIdBinderGeneric<TContract> binder) where TContract : ComponentSystemBase
{
return binder.FromMethod(
c =>
{
var contract = (TContract)c.Container.Resolve<World>().GetExistingSystem(typeof(TContract));
c.Container.Inject(contract);
return contract;
})
.NonLazy();
}
}
}