42 lines
826 B
C#
42 lines
826 B
C#
using System;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
|
|
namespace Cryville.Crtr.UI {
|
|
[RequireComponent(typeof(CanvasGroup))]
|
|
public class Popup : MonoBehaviour {
|
|
CanvasGroup _group;
|
|
[SerializeField]
|
|
TextMeshProUGUI m_text;
|
|
public string Message {
|
|
get { return m_text.text; }
|
|
set { m_text.text = value; }
|
|
}
|
|
|
|
[SerializeField]
|
|
AnimationCurve m_fadeCurve;
|
|
float _timer;
|
|
|
|
void Awake() {
|
|
_group = GetComponent<CanvasGroup>();
|
|
_group.alpha = 0;
|
|
}
|
|
|
|
void Update() {
|
|
_timer += Time.deltaTime;
|
|
_group.alpha = m_fadeCurve.Evaluate(_timer);
|
|
if (_timer > m_fadeCurve[m_fadeCurve.length - 1].time) {
|
|
Destroy(gameObject);
|
|
}
|
|
}
|
|
|
|
public static void CreateException(Exception ex) {
|
|
Create(ex.Message);
|
|
}
|
|
|
|
public static void Create(string msg) {
|
|
PopupManager.Instance.Create(msg);
|
|
}
|
|
}
|
|
}
|