All working with the build - update initialization order for the ItemManager

This commit is contained in:
Michal Pikulski
2025-09-29 13:25:22 +02:00
parent 1f614009fc
commit 8e93d40033

View File

@@ -69,14 +69,14 @@ namespace Core
{
// Subscribe to scene load completed so we can clear registrations when scenes change
// Access Instance directly to ensure the service is initialized and we get the event hookup.
SceneManagerService.Instance.SceneLoadCompleted += OnSceneLoadCompleted;
SceneManagerService.Instance.SceneLoadStarted += OnSceneLoadStarted;
}
void OnDestroy()
{
// Unsubscribe from SceneManagerService
if (SceneManagerService.Instance != null)
SceneManagerService.Instance.SceneLoadCompleted -= OnSceneLoadCompleted;
SceneManagerService.Instance.SceneLoadStarted -= OnSceneLoadStarted;
// Ensure we clean up any subscriptions from registered items when the manager is destroyed
ClearAllRegistrations();
@@ -87,7 +87,7 @@ namespace Core
_isQuitting = true;
}
private void OnSceneLoadCompleted(string sceneName)
private void OnSceneLoadStarted(string sceneName)
{
// Clear all registrations when a new scene is loaded, so no stale references persist
ClearAllRegistrations();