using System.Collections; using UnityEngine; using UnityEngine.UI; namespace WildAttack { public class TipText : MonoBehaviour { private static TipText _Instance; void Awake() { _Instance = this; gameObject.SetActive(false); } void Notify(string text) { gameObject.SetActive(true); GetComponentInChildren().text = text; LayoutRebuilder.ForceRebuildLayoutImmediate(GetComponent()); StopCoroutine("DelayHide"); StartCoroutine("DelayHide"); } IEnumerator DelayHide() { yield return new WaitForSeconds(3); gameObject.SetActive(false); } public static void Show(string text) { if (_Instance) _Instance.Notify("提示\n" + text); } } }