2023-09-04 12:48:24 +03:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
public class UIDisplayMessage : MonoBehaviour
|
|
|
|
{
|
|
|
|
[SerializeField]
|
|
|
|
private TMPro.TextMeshProUGUI _textField;
|
|
|
|
[SerializeField]
|
|
|
|
private UIProgressBar _progressBar;
|
|
|
|
|
2023-09-05 17:38:11 +03:00
|
|
|
private float _time;
|
2023-09-04 12:48:24 +03:00
|
|
|
public void Init(DisplayMessage info)
|
|
|
|
{
|
|
|
|
_textField.SetText(info.Message);
|
2023-09-05 17:38:11 +03:00
|
|
|
_time = info.Time;
|
|
|
|
|
|
|
|
Hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool IsShow = false;
|
|
|
|
|
|
|
|
private LTDescr LTDescr;
|
|
|
|
|
|
|
|
public void Show()
|
|
|
|
{
|
|
|
|
if (IsShow)
|
|
|
|
{
|
|
|
|
LeanTween.cancel(LTDescr.id);
|
|
|
|
LTDescr = LeanTween.value(1, 0, _time).setOnUpdate((float x) =>
|
|
|
|
{
|
|
|
|
_progressBar.ChangeValue(x);
|
|
|
|
}).setOnComplete(Hide);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
IsShow = true;
|
|
|
|
gameObject.SetActive(true);
|
|
|
|
LTDescr = LeanTween.value(1, 0, _time).setOnUpdate((float x) =>
|
|
|
|
{
|
|
|
|
_progressBar.ChangeValue(x);
|
|
|
|
}).setOnComplete(Hide);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Hide()
|
|
|
|
{
|
|
|
|
IsShow = false;
|
|
|
|
gameObject.SetActive(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void StopMessage()
|
|
|
|
{
|
|
|
|
Hide();
|
2023-09-04 12:48:24 +03:00
|
|
|
}
|
|
|
|
}
|