Generic Unity game startup flow scaffold. Encapsulates the full pipeline from app launch to hotfix loading with primary-backup URL failover, YooAsset patching, and pluggable UI/hotfix backends.
- One-line entry:
await StartupRunner.Run(options, uiHandler, hotfixLauncher) - Config-driven:
StartupOptionsScriptableObject with 10 fields (URL list, hotfix entry, HTTP params, UI resource) - Primary-backup failover:
GlobalInfoUrls[]withMaxAttemptsPerUrlretry policy - Backend-agnostic UI:
IStartupUIHandlerinterface — works with FairyGUI, UGUI, or any custom UI - Backend-agnostic hotfix:
IHotfixLauncherinterface — works with HybridCLR or any hotfix solution - Dual-track completion:
UniTask<StartupResult>await +StartupCompleted/FailedEventArgsevents (both fire) - PlayMode-aware:
EditorSimulateMode/OfflinePlayMode/HostPlayMode/WebPlayModebranches - YooAsset integration: Standard patch flow (init → static version → manifest → download → done)
- No channel SDK calls: Channel/SubChannel fields are pure data, no SDK dependencies
Add to Packages/manifest.json:
{
"dependencies": {
"com.gameframex.unity.startup": "1.1.0"
},
"scopedRegistries": [
{
"name": "GameFrameX",
"url": "https://gameframex.upm.alianblank.uk",
"scopes": ["com.gameframex"]
}
]
}scopes controls which packages are resolved through this registry. Only packages whose names start with com.gameframex will be fetched from it.
In Unity Editor: Create > GameFrameX > Startup Options. Configure:
GlobalInfoUrls: primary + backup URLs for the global info APIHotfixAssemblyName/HotfixEntryTypeName/HotfixEntryMethodName: hotfix entry pointsPackageName/Channel/SubChannel: HTTP public paramsLauncherUIResName: UI resource path (defaultUI/UILauncher)
public class GameStartupUIHandler : IStartupUIHandler
{
public UniTask StartAsync(string uiResName) { /* load UI */ }
public void SetTipText(string text) { /* update tip label */ }
public void SetProgress(float progress, string sizeInfo) { /* update progress bar */ }
public void SetProgressUpdateFinish() { /* mark complete */ }
public void Dispose() { /* close UI, release subscriptions */ }
}public class HybridClrHotfixLauncher : IHotfixLauncher
{
public async UniTask<HotfixLaunchResult> StartAsync(StartupOptions options)
{
// Load hotfix assembly by options.HotfixAssemblyName
// Invoke options.HotfixEntryTypeName.options.HotfixEntryMethodName
return HotfixLaunchResult.Succeed();
}
}public class GameBootstrap : MonoBehaviour
{
[SerializeField] private StartupOptions _options;
private async void Start()
{
var uiHandler = new GameStartupUIHandler();
var hotfixLauncher = new HybridClrHotfixLauncher();
var result = await StartupRunner.Run(_options, uiHandler, hotfixLauncher);
if (result.Success)
{
// Startup completed — game ready
}
else
{
Debug.LogError($"Startup failed at {result.FailedProcedureName}: {result.ErrorMessage}");
}
}
}Alternatively, subscribe to events for decoupled notification:
GameApp.Event.Subscribe(StartupCompletedEventArgs.EventId, OnStartupCompleted);
GameApp.Event.Subscribe(StartupFailedEventArgs.EventId, OnStartupFailed);| Type | Description |
|---|---|
StartupOptions |
ScriptableObject config asset (10 fields) |
StartupResult |
Return value with Success / FailedProcedureName / FailedUrl / ErrorMessage |
HotfixLaunchResult |
Hotfix-specific result with Success / ErrorMessage |
IStartupUIHandler |
UI operations interface (5 methods) |
IHotfixLauncher |
Hotfix launch interface (1 async method) |
StartupCompletedEventArgs |
Success notification event |
StartupFailedEventArgs |
Failure notification event with diagnostic fields |
StartupRunner |
Static entry — Run(options, uiHandler, hotfixLauncher) |
UrlFailoverRunner |
Ordered URL failover helper with bounded retry attempts |
UrlAttemptResult / UrlFailoverResult |
Value structs for failover attempt and final results |
StartupHttpParams |
HTTP base parameter container with JSON serialization |
The package injects 3 fixed keys into the procedure FSM for cross-state data sharing:
| Key | Type | Content |
|---|---|---|
__startup_options__ |
VarObject |
The StartupOptions instance |
__startup_ui_handler__ |
VarObject |
The IStartupUIHandler instance |
__startup_hotfix_launcher__ |
VarObject |
The IHotfixLauncher instance |
Constants available at GameFrameX.Startup.Runtime.Constants.BlackBoardKeys.
com.gameframex.unity(GameApp facade, Utility, ReferencePool)com.gameframex.unity.procedure(ProcedureBase, IProcedureManager)com.gameframex.unity.fsm(IFsm, IFsmManager)com.gameframex.unity.event(GameEventArgs, EventComponent.Fire)com.gameframex.unity.cysharp.unitask(UniTask, UniTaskCompletionSource)- Unity 2019.4+
See LICENSE.md for details.