| 12345678910111213141516171819202122232425262728293031323334353637 |
- using System.Collections;
- using UnityEngine;
- using UnityEngine.UI;
- namespace DuckHunter
- {
- public class TextSmartBowTip : MonoBehaviour
- {
- private static TextSmartBowTip _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(text);
- }
- }
- }
|