From eedbbb2b4790b4cca7ae1ecdaa98ef326a68e4dc Mon Sep 17 00:00:00 2001 From: Gabriel Kaszewski Date: Thu, 14 May 2026 01:27:56 +0200 Subject: [PATCH] fix: unsubscribe UI events on destroy, add Ui header in GameBootstrap --- Assets/Scripts/Infrastructure/Unity/GameBootstrap.cs | 1 + Assets/Scripts/Infrastructure/Unity/GameUiCoordinator.cs | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/Assets/Scripts/Infrastructure/Unity/GameBootstrap.cs b/Assets/Scripts/Infrastructure/Unity/GameBootstrap.cs index 5847c72..d49687e 100644 --- a/Assets/Scripts/Infrastructure/Unity/GameBootstrap.cs +++ b/Assets/Scripts/Infrastructure/Unity/GameBootstrap.cs @@ -22,6 +22,7 @@ namespace Infrastructure.Unity [SerializeField] private HunterNpcController hunterNpcPrefab; [SerializeField] private FloorVisibilityManager floorVisibilityManager; + [Header("Ui")] [SerializeField] private GameUiCoordinator uiCoordinator; [Header("Settings")] diff --git a/Assets/Scripts/Infrastructure/Unity/GameUiCoordinator.cs b/Assets/Scripts/Infrastructure/Unity/GameUiCoordinator.cs index e1608b4..791cbd5 100644 --- a/Assets/Scripts/Infrastructure/Unity/GameUiCoordinator.cs +++ b/Assets/Scripts/Infrastructure/Unity/GameUiCoordinator.cs @@ -23,6 +23,13 @@ namespace Infrastructure.Unity session.OnGameOver += ShowGameOverUi; } + private void OnDestroy() + { + if (_session == null) return; + _session.OnScoreChanged -= UpdateScore; + _session.OnGameOver -= ShowGameOverUi; + } + public void ShowStartScreen() { if (gameOverUi) gameOverUi.SetActive(false);