상호작용 ui 수정
This commit is contained in:
parent
15c7dd0f04
commit
0f3a958b96
@ -1,5 +1,4 @@
|
|||||||
using TMPro;
|
using TMPro;
|
||||||
using Unity.VisualScripting;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Localization;
|
using UnityEngine.Localization;
|
||||||
using UnityEngine.Localization.Components;
|
using UnityEngine.Localization.Components;
|
||||||
@ -18,29 +17,24 @@ public class InteractionMessageUi : BaseUi, IEventHandler<ShowInteractionUiEvent
|
|||||||
|
|
||||||
private LocalizedString _previousLocalizedString;
|
private LocalizedString _previousLocalizedString;
|
||||||
|
|
||||||
protected override void Awake()
|
protected override void OnDestroy()
|
||||||
{
|
{
|
||||||
base.Awake();
|
base.OnDestroy();
|
||||||
|
|
||||||
_filledImage.fillAmount = 0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnOpenedEvents()
|
|
||||||
{
|
|
||||||
base.OnOpenedEvents();
|
|
||||||
|
|
||||||
EventBus.Register<ShowInteractionUiEvent>(this);
|
|
||||||
EventBus.Register<HideInteractionUiEvent>(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnClosedEvents()
|
|
||||||
{
|
|
||||||
base.OnClosedEvents();
|
|
||||||
|
|
||||||
EventBus.Unregister<ShowInteractionUiEvent>(this);
|
EventBus.Unregister<ShowInteractionUiEvent>(this);
|
||||||
EventBus.Unregister<HideInteractionUiEvent>(this);
|
EventBus.Unregister<HideInteractionUiEvent>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnCreatedInitialize()
|
||||||
|
{
|
||||||
|
base.OnCreatedInitialize();
|
||||||
|
|
||||||
|
_filledImage.fillAmount = 0f;
|
||||||
|
|
||||||
|
EventBus.Register<ShowInteractionUiEvent>(this);
|
||||||
|
EventBus.Register<HideInteractionUiEvent>(this);
|
||||||
|
}
|
||||||
|
|
||||||
public void Invoke(ShowInteractionUiEvent evt)
|
public void Invoke(ShowInteractionUiEvent evt)
|
||||||
{
|
{
|
||||||
ShowInteractionUiEvent(evt);
|
ShowInteractionUiEvent(evt);
|
||||||
|
@ -109,7 +109,7 @@ public bool HasMatchingPopupUis(GameFlowState flowState)
|
|||||||
|
|
||||||
public void CreateUi(BaseUi ui, Transform parent)
|
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);
|
var instance = Instantiate(ui, parent);
|
||||||
instance.name = ui.name;
|
instance.name = ui.name;
|
||||||
@ -118,7 +118,7 @@ public void CreateUi(BaseUi ui, Transform parent)
|
|||||||
|
|
||||||
public void DestroyUi(BaseUi ui)
|
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);
|
Destroy(ui.gameObject);
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,10 @@ private void OnDestroy()
|
|||||||
|
|
||||||
public void PreInit()
|
public void PreInit()
|
||||||
{
|
{
|
||||||
ClearAll();
|
Utils.DestroyAllChildren(_hudRoot);
|
||||||
|
Utils.DestroyAllChildren(_interactionUiRoot);
|
||||||
|
Utils.DestroyAllChildren(_popupUiRoot);
|
||||||
|
Utils.DestroyAllChildren(_commonUiRoot);
|
||||||
|
|
||||||
GameFlowManager.Instance.FlowHandlers.Add(this);
|
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)
|
public Task OnReadyNewFlow(GameFlowState newFlowState)
|
||||||
{
|
{
|
||||||
var flowToUiMapping = UiData.FlowToUiMapping;
|
var flowToUiMapping = UiData.FlowToUiMapping;
|
||||||
|
Loading…
Reference in New Issue
Block a user