An extension to DI Framework that allows defining a specific order of execution for gameplay systems.
Developed and tested with Unity 2020.3.16f1
- Install DI Framework
- Open Package Manager through Window/Package Manager
- Click "+" and choose "Add package from git URL..."
- Insert the URL: https://github.com/Delt06/di-systems.git?path=Packages/com.deltation.di-systems
Add the following line to Packages/manifest.json
:
"com.deltation.di-systems": "https://github.com/Delt06/di-systems.git?path=Packages/com.deltation.di-systems",
Create a system:
using DELTation.DIFramework.Systems;
using UnityEngine;
public class HelloWorldSystem : IInitSystem
{
public void Init()
{
Debug.Log("Hello DI Systems!");
}
}
Create a system runner:
using DELTation.DIFramework.Systems;
public class GameSystemsRunner : SystemsRunnerBase
{
protected override void ConstructSystems()
{
Add<HelloWorldSystem>();
}
}
Create/modify your custom dependency container:
using DELTation.DIFramework;
using DELTation.DIFramework.Containers;
public class DiCompositionRoot : DependencyContainerBase
{
protected override void ComposeDependencies(ICanRegisterContainerBuilder builder)
{
builder.Register<GameSystemsRunner>();
}
}
Do not forget to attach a ContainerLifecyle
for your custom container: