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.
InitializationManagerbuilds aBusRegistrywith its buses and hands it toServiceLocatorbefore any project code registers systems. - Collect initializable components.
InitializationRegistryholds the sync and async components until they're run. Components registered throughInitializationManager.SafeRegisterare constructed safely, so one that fails to construct doesn't stop bootstrap. - Run the initialization sequence.
InitializationOrchestratorruns sync components in order, then runs async components concurrently, and the manager raisesSystemsReadywhen they finish.
Who should use it
- Project developers who write a concrete subclass of
InitializationManagerfor their first scene and register their systems inRegisterSystems. - Developers of SaffronLibrary systems who need their components to run during boot by implementing
IInitializableorIAsyncInitializable. - Anyone debugging startup order who needs to know which component runs when, and why a system was not ready.