docs
Systems
Execution
InitializationSystem
InitializationSystem Overview

The InitializationSystem bootstraps a SaffronLibrary application by creating the messaging bus registry, collecting the components that need setup, and running their initialization in a fixed order. It is the entry point that turns a scene's startup into a known, ordered sequence.

Purpose in SaffronLibrary

SaffronLibrary is a set of reusable systems for Unity projects. Many of those systems need other systems to be ready before they can work, such as a bus registry, a data layer, or event subscribers. This system provides the single startup path that creates the shared messaging services, runs each registered component's setup, and announces when the whole sequence has finished through the SystemsReady signal.

Key responsibilities

  • Bootstrap the messaging services. InitializationManager builds a BusRegistry with its buses and hands it to ServiceLocator before any project code registers systems.
  • Collect initializable components. InitializationRegistry holds the sync and async components until they're run. Components registered through InitializationManager.SafeRegister are constructed safely, so one that fails to construct doesn't stop bootstrap.
  • Run the initialization sequence. InitializationOrchestrator runs sync components in order, then runs async components concurrently, and the manager raises SystemsReady when they finish.

Who should use it

  • Project developers who write a concrete subclass of InitializationManager for their first scene and register their systems in RegisterSystems.
  • Developers of SaffronLibrary systems who need their components to run during boot by implementing IInitializable or IAsyncInitializable.
  • Anyone debugging startup order who needs to know which component runs when, and why a system was not ready.