baseUi 기반으로 ui들 수정
This commit is contained in:
parent
c2ecdad492
commit
9572e9335a
@ -15,6 +15,11 @@ protected virtual void Awake()
|
|||||||
_canvasGroup = GetComponent<CanvasGroup>();
|
_canvasGroup = GetComponent<CanvasGroup>();
|
||||||
_panel = transform.Find(CommonConstants.Panel).gameObject;
|
_panel = transform.Find(CommonConstants.Panel).gameObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected virtual void OnEnable()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
protected virtual void Start()
|
protected virtual void Start()
|
||||||
{
|
{
|
||||||
@ -27,6 +32,11 @@ protected virtual void Update()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected virtual void OnDisable()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
protected virtual void OnDestroy()
|
protected virtual void OnDestroy()
|
||||||
{
|
{
|
||||||
TryUnregister();
|
TryUnregister();
|
||||||
|
@ -1,48 +1,54 @@
|
|||||||
|
using System.Threading.Tasks;
|
||||||
using DG.Tweening;
|
using DG.Tweening;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace DDD
|
namespace DDD
|
||||||
{
|
{
|
||||||
public class FadeUi : MonoBehaviour, IEventHandler<FadeInEvent>, IEventHandler<FadeOutEvent>
|
public class FadeUi : BaseUi, IEventHandler<FadeInEvent>, IEventHandler<FadeOutEvent>
|
||||||
{
|
{
|
||||||
private CanvasGroup _canvasGroup;
|
protected override void Awake()
|
||||||
private GameObject _panel;
|
|
||||||
|
|
||||||
private void Awake()
|
|
||||||
{
|
{
|
||||||
_canvasGroup = GetComponent<CanvasGroup>();
|
base.Awake();
|
||||||
_panel = transform.Find(CommonConstants.Panel).gameObject;
|
|
||||||
|
|
||||||
_canvasGroup.alpha = 0f;
|
_canvasGroup.alpha = 0f;
|
||||||
_panel.SetActive(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnEnable()
|
protected override void TryRegister()
|
||||||
{
|
{
|
||||||
EventBus.Register<FadeInEvent>(this);
|
EventBus.Register<FadeInEvent>(this);
|
||||||
EventBus.Register<FadeOutEvent>(this);
|
EventBus.Register<FadeOutEvent>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnDisable()
|
protected override void TryUnregister()
|
||||||
{
|
{
|
||||||
EventBus.Unregister<FadeInEvent>(this);
|
EventBus.Unregister<FadeInEvent>(this);
|
||||||
EventBus.Unregister<FadeOutEvent>(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)
|
await _canvasGroup.DOFade(0f, evt.Duration)
|
||||||
.SetUpdate(true)
|
.SetUpdate(true)
|
||||||
.AsyncWaitForCompletion();
|
.AsyncWaitForCompletion();
|
||||||
|
|
||||||
_panel.SetActive(false);
|
ClosePanel();
|
||||||
|
|
||||||
evt.CompletionSource.SetResult(true);
|
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)
|
await _canvasGroup.DOFade(1f, evt.Duration)
|
||||||
.SetUpdate(true)
|
.SetUpdate(true)
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
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;
|
||||||
@ -11,35 +12,50 @@ public class InteractionMessageUi : BaseUi, IEventHandler<ShowInteractionUiEvent
|
|||||||
[SerializeField] private Image _filledImage;
|
[SerializeField] private Image _filledImage;
|
||||||
[SerializeField] private TextMeshProUGUI _textLabel;
|
[SerializeField] private TextMeshProUGUI _textLabel;
|
||||||
[SerializeField] private LocalizeStringEvent _textLabelLocalizeStringEvent;
|
[SerializeField] private LocalizeStringEvent _textLabelLocalizeStringEvent;
|
||||||
|
|
||||||
[SerializeField] private Color _canInteractTextColor = Color.white;
|
[SerializeField] private Color _canInteractTextColor = Color.white;
|
||||||
[SerializeField] private Color _cannotInteractTextColor = Color.gray2;
|
[SerializeField] private Color _cannotInteractTextColor = Color.gray2;
|
||||||
|
|
||||||
private LocalizedString _previousLocalizedString;
|
private LocalizedString _previousLocalizedString;
|
||||||
|
|
||||||
protected override void Start()
|
protected override void Awake()
|
||||||
{
|
{
|
||||||
base.Start();
|
base.Awake();
|
||||||
|
|
||||||
_filledImage.fillAmount = 0f;
|
_filledImage.fillAmount = 0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void TryRegister()
|
||||||
|
{
|
||||||
|
base.TryRegister();
|
||||||
|
|
||||||
EventBus.Register<ShowInteractionUiEvent>(this);
|
EventBus.Register<ShowInteractionUiEvent>(this);
|
||||||
EventBus.Register<HideInteractionUiEvent>(this);
|
EventBus.Register<HideInteractionUiEvent>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnDestroy()
|
protected override void TryUnregister()
|
||||||
{
|
{
|
||||||
base.OnDestroy();
|
base.TryUnregister();
|
||||||
|
|
||||||
EventBus.Unregister<ShowInteractionUiEvent>(this);
|
EventBus.Unregister<ShowInteractionUiEvent>(this);
|
||||||
EventBus.Unregister<HideInteractionUiEvent>(this);
|
EventBus.Unregister<HideInteractionUiEvent>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Invoke(ShowInteractionUiEvent evt)
|
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);
|
_previousLocalizedString = LocalizationManager.Instance.GetLocalizedString(evt.TextKey);
|
||||||
_textLabel.color = evt.CanInteract ? _canInteractTextColor : _cannotInteractTextColor;
|
_textLabel.color = evt.CanInteract ? _canInteractTextColor : _cannotInteractTextColor;
|
||||||
|
|
||||||
if (_textLabelLocalizeStringEvent.StringReference != _previousLocalizedString)
|
if (_textLabelLocalizeStringEvent.StringReference != _previousLocalizedString)
|
||||||
{
|
{
|
||||||
_textLabelLocalizeStringEvent.StringReference = _previousLocalizedString;
|
_textLabelLocalizeStringEvent.StringReference = _previousLocalizedString;
|
||||||
@ -52,7 +68,7 @@ public void Invoke(ShowInteractionUiEvent evt)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Invoke(HideInteractionUiEvent evt)
|
private void HideInteractionUiEvent(HideInteractionUiEvent evt)
|
||||||
{
|
{
|
||||||
_filledImage.fillAmount = 0f;
|
_filledImage.fillAmount = 0f;
|
||||||
ClosePanel();
|
ClosePanel();
|
||||||
|
Loading…
Reference in New Issue
Block a user