The bootstrap feature creates the main game context, runs startup commands, and registers async data sources in a predictable order.
The UNIGAME_BOOTSTRAP_ENABLED define is no longer required to use the bootstrap API.
- Without the define, you can start the bootstrap manually.
- With the define,
GameBootstrap.AutoInitializeGame()runs automatically after scene load.
GameBootstrap is responsible for:
- creating the root
EntityContext - assigning
GameContext.Context - initializing Addressables
- loading
GameBootSettings - executing boot commands
- registering configured async sources
Public entry points:
GameBootstrap.InitializeGame()starts bootstrap in fire-and-forget modeGameBootstrap.InitializeGameAsync()runs the full pipeline as an awaitable taskGameBootstrap.Restart()disposes the current lifetime and starts bootstrap againGameBootstrap.Dispose()terminates the current bootstrap lifetimeGameBootstrap.Contextexposes the current root contextGameBootstrap.LifeTimeexposes the current bootstrap lifetime
The runtime pipeline is executed in this order:
InitializeAddressableAsyncInitializeAsyncExecuteBootInitStepsAsyncInitializeServicesAsync
The bootstrap begins with Addressables.InitializeAsync().
GameBootSettings is loaded by the addressable key GameBootSettings.
If the addressable asset is not found, the bootstrap falls back to Resources.Load<GameBootSettings>().
This gives you two supported setup options:
- Create a
GameBootSettingsasset anywhere in the project and mark it addressable with the keyGameBootSettings. - Put a
GameBootSettingsasset in aResourcesfolder.
Asset menu:
UniGame/Bootstrap/GameBootSettings
Boot commands are defined in GameBootSettings.gameInitCommands and executed sequentially.
Each command implements IGameBootCommand:
public interface IGameBootCommand
{
UniTask<BootStepResult> ExecuteAsync(IContext context);
}BootStepResult controls error handling:
success = true: continue normallysuccess = falseandcanContinue = true: log the error and continuesuccess = falseandcanContinue = false: stop the bootstrap
Example:
using Cysharp.Threading.Tasks;
using UniGame.Core.Runtime;
using UniGame.Features.Bootstrap;
public class WarmupCommand : IGameBootCommand
{
public async UniTask<BootStepResult> ExecuteAsync(IContext context)
{
await UniTask.Yield();
return new BootStepResult
{
success = true,
canContinue = true,
error = string.Empty,
};
}
}The package also includes a sample command: CheckAndClearBundleCacheByVersionCommand.
After all boot commands complete, GameBootstrap registers the GameBootSettings.source asset.
This field is an AsyncContextSource, which means bootstrap sources are executed as an ordered pipeline of async data sources.
Create source assets from:
UniGame/Context/Async Data Sources
Each entry inside GameBootSettings.source.asyncSources has an awaitLoading flag.
This flag defines whether a source is a synchronization barrier in the bootstrap pipeline.
awaitLoading = false: the source is grouped with adjacent non-awaited sources and loaded in parallel inside the same stepawaitLoading = true: the source becomes its own awaited step, and bootstrap does not continue until it finishes
In practice, this lets you split initialization into stages.
Example configuration:
AnalyticsSourcewithawaitLoading = falseDebugServiceSourcewithawaitLoading = falseRemoteSettingsSourcewithawaitLoading = trueAudioSourcewithawaitLoading = falseGameplaySourcewithawaitLoading = true
Effective execution steps:
- Load
AnalyticsSourceandDebugServiceSourcein parallel - Await
RemoteSettingsSource - Load
AudioSource - Await
GameplaySource
Use this when some services can start in the background, but later systems must wait for critical dependencies such as remote config, save migration, authentication, or content manifests.
GameBootSettings contains two main parts:
gameInitCommands: sequential startup commandssource: async source pipeline used to register services and features into the root context
Editor helpers:
Fill()scans availableDataSourceAssetassets and adds missing ones to the source listSave()persists the asset after editing
Use manual startup when you want to control bootstrap timing yourself.
using Cysharp.Threading.Tasks;
using Game.Runtime.Services.Bootstrap;
public static class EntryPoint
{
public static async UniTask StartAsync()
{
await GameBootstrap.InitializeGameAsync();
}
}You can also call:
GameBootstrap.InitializeGame();If UNIGAME_BOOTSTRAP_ENABLED is defined, bootstrap starts automatically through RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterSceneLoad).
This define only enables auto-start. It does not gate the bootstrap feature itself.
- Keep
gameInitCommandsfocused on explicit boot actions that must happen before source registration. - Put long-lived services into async sources instead of commands when they belong to context composition.
- Use
awaitLoading = trueonly for sources that are true dependencies for later boot steps. - Use
awaitLoading = falsefor services that can be registered in parallel without blocking the rest of startup. - Prefer
InitializeGameAsync()in tests or controlled startup flows where you need deterministic completion.
Use GameBootstrap when you need a single entry point for startup orchestration:
- manual or automatic game initialization
- ordered boot commands with failure control
- context creation and lifetime management
- step-based async service registration with
awaitLoading