baseUi 기반으로 ui들 수정

This commit is contained in:
NTG 2025-08-14 17:21:17 +09:00
parent c2ecdad492
commit 9572e9335a
3 changed files with 55 additions and 23 deletions

View File

@ -16,6 +16,11 @@ protected virtual void Awake()
_panel = transform.Find(CommonConstants.Panel).gameObject;
}
protected virtual void OnEnable()
{
}
protected virtual void Start()
{
TryRegister();
@ -27,6 +32,11 @@ protected virtual void Update()
}
protected virtual void OnDisable()
{
}
protected virtual void OnDestroy()
{
TryUnregister();

View File

@ -1,48 +1,54 @@
using System.Threading.Tasks;
using DG.Tweening;
using UnityEngine;
namespace DDD
{
public class FadeUi : MonoBehaviour, IEventHandler<FadeInEvent>, IEventHandler<FadeOutEvent>
public class FadeUi : BaseUi, IEventHandler<FadeInEvent>, IEventHandler<FadeOutEvent>
{
private CanvasGroup _canvasGroup;
private GameObject _panel;
private void Awake()
protected override void Awake()
{
_canvasGroup = GetComponent<CanvasGroup>();
_panel = transform.Find(CommonConstants.Panel).gameObject;
base.Awake();
_canvasGroup.alpha = 0f;
_panel.SetActive(false);
}
private void OnEnable()
protected override void TryRegister()
{
EventBus.Register<FadeInEvent>(this);
EventBus.Register<FadeOutEvent>(this);
}
private void OnDisable()
protected override void TryUnregister()
{
EventBus.Unregister<FadeInEvent>(this);
EventBus.Unregister<FadeOutEvent>(this);
}
public async void Invoke(FadeInEvent evt)
public void Invoke(FadeInEvent evt)
{
_ = FadeInAsync(evt);
}
public void Invoke(FadeOutEvent evt)
{
_ = FadeOutAsync(evt);
}
private async Task FadeInAsync(FadeInEvent evt)
{
await _canvasGroup.DOFade(0f, evt.Duration)
.SetUpdate(true)
.AsyncWaitForCompletion();
_panel.SetActive(false);
ClosePanel();
evt.CompletionSource.SetResult(true);
}
public async void Invoke(FadeOutEvent evt)
private async Task FadeOutAsync(FadeOutEvent evt)
{
_panel.SetActive(true);
OpenPanel();
await _canvasGroup.DOFade(1f, evt.Duration)
.SetUpdate(true)

View File

@ -1,4 +1,5 @@
using TMPro;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.Localization;
using UnityEngine.Localization.Components;
@ -17,25 +18,40 @@ public class InteractionMessageUi : BaseUi, IEventHandler<ShowInteractionUiEvent
private LocalizedString _previousLocalizedString;
protected override void Start()
protected override void Awake()
{
base.Start();
base.Awake();
_filledImage.fillAmount = 0f;
}
protected override void TryRegister()
{
base.TryRegister();
EventBus.Register<ShowInteractionUiEvent>(this);
EventBus.Register<HideInteractionUiEvent>(this);
}
protected override void OnDestroy()
protected override void TryUnregister()
{
base.OnDestroy();
base.TryUnregister();
EventBus.Unregister<ShowInteractionUiEvent>(this);
EventBus.Unregister<HideInteractionUiEvent>(this);
}
public void Invoke(ShowInteractionUiEvent evt)
{
ShowInteractionUiEvent(evt);
}
public void Invoke(HideInteractionUiEvent evt)
{
HideInteractionUiEvent(evt);
}
private void ShowInteractionUiEvent(ShowInteractionUiEvent evt)
{
_previousLocalizedString = LocalizationManager.Instance.GetLocalizedString(evt.TextKey);
_textLabel.color = evt.CanInteract ? _canInteractTextColor : _cannotInteractTextColor;
@ -52,7 +68,7 @@ public void Invoke(ShowInteractionUiEvent evt)
}
}
public void Invoke(HideInteractionUiEvent evt)
private void HideInteractionUiEvent(HideInteractionUiEvent evt)
{
_filledImage.fillAmount = 0f;
ClosePanel();