30 lines
572 B
C#
30 lines
572 B
C#
using TMPro;
|
|
using UnityEngine;
|
|
|
|
public class PopUps : MonoBehaviour
|
|
{
|
|
public static PopUps Instance;
|
|
|
|
public GameObject PopUpPrefab;
|
|
GameObject currentObject;
|
|
|
|
private void Awake()
|
|
{
|
|
Instance = this;
|
|
}
|
|
|
|
public static void Create(string text = "hello world", float duration = 8)
|
|
{
|
|
if (!Instance)
|
|
return;
|
|
if (Instance.currentObject)
|
|
Destroy(Instance.currentObject);
|
|
|
|
Instance.currentObject = Instantiate(Instance.PopUpPrefab);
|
|
|
|
var popUp = Instance.currentObject.GetComponent<PopUp>();
|
|
popUp.Text.text = text;
|
|
popUp.DestroyTime = duration;
|
|
}
|
|
}
|