42 lines
783 B
C#
42 lines
783 B
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class InteractionPromptUI : MonoBehaviour
|
|
{
|
|
public static InteractionPromptUI Instance { get; private set; }
|
|
|
|
public GameObject root;
|
|
public Text promptText;
|
|
|
|
private void Awake()
|
|
{
|
|
if (Instance != null && Instance != this)
|
|
{
|
|
Destroy(gameObject);
|
|
return;
|
|
}
|
|
|
|
Instance = this;
|
|
Hide();
|
|
}
|
|
|
|
public void Show(string message)
|
|
{
|
|
if (root == null || promptText == null || string.IsNullOrWhiteSpace(message))
|
|
{
|
|
return;
|
|
}
|
|
|
|
promptText.text = message;
|
|
root.SetActive(true);
|
|
}
|
|
|
|
public void Hide()
|
|
{
|
|
if (root != null)
|
|
{
|
|
root.SetActive(false);
|
|
}
|
|
}
|
|
}
|