Semi-working intro cinematic with loading screen
This commit is contained in:
@@ -12,8 +12,7 @@ namespace Core
|
||||
/// </summary>
|
||||
public class SceneManagerService : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private LoadingScreenController loadingScreen;
|
||||
|
||||
private LoadingScreenController _loadingScreen;
|
||||
private static SceneManagerService _instance;
|
||||
private static bool _isQuitting = false;
|
||||
/// <summary>
|
||||
@@ -49,6 +48,15 @@ namespace Core
|
||||
private readonly Dictionary<string, AsyncOperation> _activeUnloads = new();
|
||||
private const string BootstrapSceneName = "BootstrapScene";
|
||||
|
||||
void Start()
|
||||
{
|
||||
_loadingScreen = LoadingScreenController.Instance;
|
||||
|
||||
// Set up loading screen event handlers
|
||||
SetupLoadingScreenEvents();
|
||||
}
|
||||
|
||||
|
||||
void Awake()
|
||||
{
|
||||
_instance = this;
|
||||
@@ -64,9 +72,6 @@ namespace Core
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// Set up loading screen event handlers
|
||||
SetupLoadingScreenEvents();
|
||||
|
||||
// Ensure BootstrapScene is loaded at startup
|
||||
var bootstrap = SceneManager.GetSceneByName(BootstrapSceneName);
|
||||
if (!bootstrap.isLoaded)
|
||||
@@ -77,10 +82,10 @@ namespace Core
|
||||
|
||||
private void SetupLoadingScreenEvents()
|
||||
{
|
||||
if (loadingScreen == null) return;
|
||||
|
||||
SceneLoadStarted += _ => loadingScreen.ShowLoadingScreen();
|
||||
SceneLoadCompleted += _ => loadingScreen.HideLoadingScreen();
|
||||
if (_loadingScreen == null) return;
|
||||
|
||||
SceneLoadStarted += _ => _loadingScreen.ShowLoadingScreen(() => GetAggregateLoadProgress());
|
||||
SceneLoadCompleted += _ => _loadingScreen.HideLoadingScreen();
|
||||
}
|
||||
|
||||
void OnApplicationQuit()
|
||||
@@ -142,9 +147,9 @@ namespace Core
|
||||
public async Task LoadScenesAsync(IEnumerable<string> sceneNames, IProgress<float> progress = null)
|
||||
{
|
||||
// Show loading screen at the start of multiple scene loading
|
||||
if (loadingScreen != null)
|
||||
if (_loadingScreen != null)
|
||||
{
|
||||
loadingScreen.ShowLoadingScreen();
|
||||
_loadingScreen.ShowLoadingScreen();
|
||||
}
|
||||
|
||||
int total = 0;
|
||||
@@ -181,9 +186,9 @@ namespace Core
|
||||
}
|
||||
|
||||
// Hide loading screen after all scenes are loaded
|
||||
if (loadingScreen != null)
|
||||
if (_loadingScreen != null)
|
||||
{
|
||||
loadingScreen.HideLoadingScreen();
|
||||
_loadingScreen.HideLoadingScreen();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,9 +200,9 @@ namespace Core
|
||||
public async Task UnloadScenesAsync(IEnumerable<string> sceneNames, IProgress<float> progress = null)
|
||||
{
|
||||
// Show loading screen at the start of multiple scene unloading
|
||||
if (loadingScreen != null)
|
||||
if (_loadingScreen != null)
|
||||
{
|
||||
loadingScreen.ShowLoadingScreen();
|
||||
_loadingScreen.ShowLoadingScreen();
|
||||
}
|
||||
|
||||
int total = 0;
|
||||
@@ -234,9 +239,9 @@ namespace Core
|
||||
}
|
||||
|
||||
// Hide loading screen after all scenes are unloaded
|
||||
if (loadingScreen != null)
|
||||
if (_loadingScreen != null)
|
||||
{
|
||||
loadingScreen.HideLoadingScreen();
|
||||
_loadingScreen.HideLoadingScreen();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user