| 123456789101112131415161718192021222324252627282930313233343536 |
- 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 = text;
- LayoutRebuilder.ForceRebuildLayoutImmediate(GetComponent<RectTransform>());
- StopCoroutine("DelayHide");
- StartCoroutine("DelayHide");
- }
- IEnumerator DelayHide()
- {
- yield return new WaitForSeconds(3);
- gameObject.SetActive(false);
- }
- public static void Show(string text)
- {
- if (_Instance) _Instance.Notify("<color=#2FFFEC>提示</color>\n" + text);
- }
- }
- }
|