Skip to content

SST-Systems/Initialization

Repository files navigation

Initialization

release release date last commit license

English | Русский


Run your async startup steps in order, with progress.

A small initialization pipeline for Unity and pure C#. Implement IInitializableAsync on any service, hand the services to InitializeManager, and it runs every Initialize() in sequence — exposing a 0..1 progress value and an OnCompleted callback. The core has no DI dependency; a Zenject integration ships as a sample.

Table Of Contents

Details

Installation

  1. .unitypackageReleases
  2. UPMWindow → Package Manager+Add package from git URL: https://github.com/SST-Systems/Initialization.git Append #tag to pin a version.
  3. Manual — clone or download, copy to Assets/.

Unity 2021.3+

The core is dependency-free — no DI framework required.


Classes

IInitializableAsync — implement on any service that needs async setup at startup. Single method Task Initialize().

IInitializeManager — the pipeline entry point: Action OnCompleted, Task Execute(), float GetInitializeProgress().

InitializeManager — default implementation. Receives the services through its constructor (IEnumerable<IInitializableAsync>) and runs them in order.


Usage

// 1. Implement IInitializableAsync on the services that need async startup
public class SaveSystem : IInitializableAsync
{
    public async Task Initialize() => await LoadFromDiskAsync();
}

// 2. Hand the services to the manager — no DI container required
var manager = new InitializeManager(new IInitializableAsync[]
{
    new SaveSystem(),
    new RemoteConfigService(),
});

// 3. Run the pipeline
manager.OnCompleted += () => Debug.Log("All systems initialized");
await manager.Execute();

// Poll progress, e.g. for a loading bar
float progress = manager.GetInitializeProgress(); // 0..1

Using a DI container? Bind your services and the manager, and let the container fill the constructor — see the Zenject for Initialization sample.


Samples

Zenject for Initialization — an installer that binds your IInitializableAsync services and InitializeManager, so the manager receives them automatically through DI. Import via Window → Package Manager → select InitializationSamples tab.


Notes

  • Services run sequentially, in the order you hand them to the constructor.
  • GetInitializeProgress() returns 1 when the list is empty, otherwise completed / total.
  • OnCompleted fires once, right after the last service finishes.
  • DI-agnostic: construct InitializeManager manually (as above) or through any container — nothing in the core references a DI framework.

License

Distributed under the MIT License. Free for personal and commercial use.

Author — Egor Shesterikov.

Releases

Contributors

Languages