55 lines
995 B
C#
55 lines
995 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class UIDisplayMessage : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private TMPro.TextMeshProUGUI _textField;
|
|
|
|
private LeanTimer _leanTimer;
|
|
|
|
private void Awake()
|
|
{
|
|
_leanTimer = GetComponent<LeanTimer>();
|
|
}
|
|
|
|
private float _time;
|
|
public void Init(DisplayMessage info)
|
|
{
|
|
_textField.SetText(info.Message);
|
|
_time = info.Time;
|
|
|
|
Hide();
|
|
}
|
|
|
|
public bool IsShow = false;
|
|
|
|
|
|
public void Show()
|
|
{
|
|
if (IsShow)
|
|
{
|
|
_leanTimer.StopTimer();
|
|
_leanTimer.StartTimer(1, 0, _time, Hide);
|
|
}
|
|
else
|
|
{
|
|
IsShow = true;
|
|
gameObject.SetActive(true);
|
|
_leanTimer.StartTimer(1, 0, _time, Hide);
|
|
}
|
|
}
|
|
|
|
public void Hide()
|
|
{
|
|
IsShow = false;
|
|
gameObject.SetActive(false);
|
|
}
|
|
|
|
public void StopMessage()
|
|
{
|
|
Hide();
|
|
}
|
|
}
|