From 0f3a958b96c8bea66f6b9f252aaad63838eeee92 Mon Sep 17 00:00:00 2001 From: NTG Date: Tue, 26 Aug 2025 16:32:59 +0900 Subject: [PATCH] =?UTF-8?q?=EC=83=81=ED=98=B8=EC=9E=91=EC=9A=A9=20ui=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../InteractionUis/InteractionMessageUi.cs | 32 ++++++++----------- .../GameUi/BaseUi/PopupUis/UiState.cs | 4 +-- Assets/_DDD/_Scripts/GameUi/UiManager.cs | 21 +++--------- 3 files changed, 19 insertions(+), 38 deletions(-) diff --git a/Assets/_DDD/_Scripts/GameUi/BaseUi/InteractionUis/InteractionMessageUi.cs b/Assets/_DDD/_Scripts/GameUi/BaseUi/InteractionUis/InteractionMessageUi.cs index 13b3bddfb..fa5191a46 100644 --- a/Assets/_DDD/_Scripts/GameUi/BaseUi/InteractionUis/InteractionMessageUi.cs +++ b/Assets/_DDD/_Scripts/GameUi/BaseUi/InteractionUis/InteractionMessageUi.cs @@ -1,5 +1,4 @@ using TMPro; -using Unity.VisualScripting; using UnityEngine; using UnityEngine.Localization; using UnityEngine.Localization.Components; @@ -18,29 +17,24 @@ public class InteractionMessageUi : BaseUi, IEventHandler(this); - EventBus.Register(this); - } - - protected override void OnClosedEvents() - { - base.OnClosedEvents(); - + base.OnDestroy(); + EventBus.Unregister(this); EventBus.Unregister(this); } + protected override void OnCreatedInitialize() + { + base.OnCreatedInitialize(); + + _filledImage.fillAmount = 0f; + + EventBus.Register(this); + EventBus.Register(this); + } + public void Invoke(ShowInteractionUiEvent evt) { ShowInteractionUiEvent(evt); diff --git a/Assets/_DDD/_Scripts/GameUi/BaseUi/PopupUis/UiState.cs b/Assets/_DDD/_Scripts/GameUi/BaseUi/PopupUis/UiState.cs index f23f7e963..ecb2e0bc5 100644 --- a/Assets/_DDD/_Scripts/GameUi/BaseUi/PopupUis/UiState.cs +++ b/Assets/_DDD/_Scripts/GameUi/BaseUi/PopupUis/UiState.cs @@ -109,7 +109,7 @@ public bool HasMatchingPopupUis(GameFlowState flowState) public void CreateUi(BaseUi ui, Transform parent) { - if (_uis.TryGetValue(ui.GetType(), out var registered) && registered == ui) return; + if (_uis.ContainsKey(ui.GetType())) return; var instance = Instantiate(ui, parent); instance.name = ui.name; @@ -118,7 +118,7 @@ public void CreateUi(BaseUi ui, Transform parent) public void DestroyUi(BaseUi ui) { - if (_uis.TryGetValue(ui.GetType(), out var registered) && registered == ui) return; + if (_uis.ContainsKey(ui.GetType())) return; Destroy(ui.gameObject); } diff --git a/Assets/_DDD/_Scripts/GameUi/UiManager.cs b/Assets/_DDD/_Scripts/GameUi/UiManager.cs index 7b1db12ef..c70640413 100644 --- a/Assets/_DDD/_Scripts/GameUi/UiManager.cs +++ b/Assets/_DDD/_Scripts/GameUi/UiManager.cs @@ -21,7 +21,10 @@ private void OnDestroy() public void PreInit() { - ClearAll(); + Utils.DestroyAllChildren(_hudRoot); + Utils.DestroyAllChildren(_interactionUiRoot); + Utils.DestroyAllChildren(_popupUiRoot); + Utils.DestroyAllChildren(_commonUiRoot); GameFlowManager.Instance.FlowHandlers.Add(this); } @@ -50,22 +53,6 @@ public void PostInit() } - private void ClearObjects(Transform root) - { - foreach (Transform child in root) - { - Destroy(child.gameObject); - } - } - - private void ClearAll() - { - ClearObjects(_hudRoot); - ClearObjects(_interactionUiRoot); - ClearObjects(_popupUiRoot); - ClearObjects(_commonUiRoot); - } - public Task OnReadyNewFlow(GameFlowState newFlowState) { var flowToUiMapping = UiData.FlowToUiMapping;