You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.0 KiB
C#
46 lines
1.0 KiB
C#
1 week ago
|
using System;
|
||
|
using System.Collections;
|
||
|
using UnityEngine;
|
||
|
|
||
|
namespace Unity.BossRoom.Gameplay.UI
|
||
|
{
|
||
|
public class UIMessageSlot : MonoBehaviour
|
||
|
{
|
||
|
[SerializeField]
|
||
|
Animator m_Animator;
|
||
|
|
||
|
[SerializeField]
|
||
|
TMPro.TextMeshProUGUI m_TextLabel;
|
||
|
|
||
|
[SerializeField]
|
||
|
float m_HideDelay = 10;
|
||
|
public bool IsDisplaying { get; private set; }
|
||
|
|
||
|
public void Display(string text)
|
||
|
{
|
||
|
if (!IsDisplaying)
|
||
|
{
|
||
|
IsDisplaying = true;
|
||
|
m_Animator.SetTrigger("Display");
|
||
|
StartCoroutine(HideCoroutine());
|
||
|
m_TextLabel.text = text;
|
||
|
transform.parent.SetAsLastSibling();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
IEnumerator HideCoroutine()
|
||
|
{
|
||
|
yield return new WaitForSeconds(m_HideDelay);
|
||
|
m_Animator.SetTrigger("Hide");
|
||
|
}
|
||
|
|
||
|
public void Hide()
|
||
|
{
|
||
|
if (IsDisplaying)
|
||
|
{
|
||
|
IsDisplaying = false;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|