test commit
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user