Author a bootstrap scene first approach

This commit is contained in:
Michal Pikulski
2025-10-16 11:06:05 +02:00
parent 1ae065b45d
commit 1ee5519716
9 changed files with 630 additions and 130 deletions

View File

@@ -1,4 +1,5 @@
using System.Threading.Tasks;
using System;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.ResourceManagement.AsyncOperations;
@@ -14,9 +15,24 @@ namespace Bootstrap
/// Current initialisation status
/// </summary>
public static bool Initialised { get; private set; }
/// <summary>
/// Event triggered when boot progress changes
/// </summary>
public static event Action<float> OnBootProgressChanged;
/// <summary>
/// Event triggered when boot process completes
/// </summary>
public static event Action OnBootCompleted;
/// <summary>
/// Current progress of the boot process (0-1)
/// </summary>
public static float CurrentProgress { get; private set; }
/// <summary>
// Called as soon as the game begins
/// Called as soon as the game begins
/// </summary>
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSplashScreen)]
private static void Initialise()
@@ -32,6 +48,9 @@ namespace Bootstrap
/// </summary>
public static void PerformInitialisation()
{
//Reset progress
CurrentProgress = 0f;
//In editor, perform initialisation synchronously
if (Application.isEditor)
{
@@ -72,6 +91,9 @@ namespace Bootstrap
{
await LoadCustomBootSettings();
Initialised = true;
CurrentProgress = 1f;
OnBootProgressChanged?.Invoke(1f);
OnBootCompleted?.Invoke();
}
/// <summary>
@@ -81,6 +103,9 @@ namespace Bootstrap
{
LoadCustomBootSettingsSync();
Initialised = true;
CurrentProgress = 1f;
OnBootProgressChanged?.Invoke(1f);
OnBootCompleted?.Invoke();
}
@@ -177,5 +202,16 @@ namespace Bootstrap
result.InitialiseSync();
return handle;
}
/// <summary>
/// Updates the current progress value and triggers the progress event
/// </summary>
/// <param name="progress">Progress value between 0-1</param>
internal static void UpdateProgress(float progress)
{
CurrentProgress = Mathf.Clamp01(progress);
OnBootProgressChanged?.Invoke(CurrentProgress);
Debug.Log($"[CustomBoot] Progress: {CurrentProgress:P0}");
}
}
}