Skip to main content

Class Bootstrapper

Wires up the application's core services once, before any scene object receives Awake or Start.

public static class Bootstrapper

Inheritance​

object→Bootstrapper

Remarks​

Registering services here rather than in a scene's Awake callback guarantees that UnityServiceLocator is fully populated before any MonoBehaviour in any scene attempts a TryGet. It also means the registrations survive across scene transitions — there is no need to re-register services when the active scene changes.

To add a new global service, create its implementation and call UnityServiceLocator.Current.Register(new MyServiceImpl()) below the existing registrations.

Methods​

Initiailze()​

Entry point invoked by Unity via [RuntimeInitializeOnLoadMethod] before any scene object's lifecycle callbacks run.

[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
public static void Initiailze()

Remarks​

RuntimeInitializeLoadType.BeforeSceneLoad is the earliest reliable hook available in Unity for code that must run before any scene object's Awake. It runs even if no scene is loaded yet (e.g., the initial empty scene during startup).