Fix initialization order for the manager objects

This commit is contained in:
Michal Pikulski
2025-10-16 11:46:51 +02:00
parent cb628ad5d6
commit 49c4d968aa
3 changed files with 36 additions and 3 deletions

View File

@@ -3,6 +3,7 @@ using Core;
using UnityEngine;
using UnityEngine.SceneManagement;
using Input;
using Bootstrap;
namespace UI
{
@@ -43,10 +44,17 @@ namespace UI
/// </summary>
public bool IsPaused => _isPaused;
private void Awake()
{
_instance = this;
// Register for post-boot initialization
BootCompletionService.RegisterInitAction(InitializePostBoot);
}
private void Start()
{
// Subscribe to scene loaded events
SceneManagerService.Instance.SceneLoadCompleted += SetPauseMenuByLevel;
// SceneManagerService subscription moved to InitializePostBoot
// Set initial state based on current scene
SetPauseMenuByLevel(SceneManager.GetActiveScene().name);
@@ -57,6 +65,13 @@ namespace UI
#endif
}
private void InitializePostBoot()
{
// Subscribe to scene loaded events
SceneManagerService.Instance.SceneLoadCompleted += SetPauseMenuByLevel;
Logging.Debug("[PauseMenu] Subscribed to SceneManagerService events");
}
private void OnDestroy()
{
// Unsubscribe when destroyed