PopupMgr.cs 802 B

123456789101112131415161718192021222324252627282930
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using DG.Tweening;
  6. public class PopupMgr
  7. {
  8. public static PopupMgr _ins;
  9. public static PopupMgr ins {
  10. get {
  11. if (_ins == null) {
  12. _ins = new PopupMgr();
  13. }
  14. return _ins;
  15. }
  16. }
  17. public void ShowTip(string text) {
  18. GameObject o = GameObject.Instantiate(Resources.Load<GameObject>("Prefabs/Popups/PopupCanvas"));
  19. Text textComp = o.transform.Find("Tip").GetComponent<Text>();
  20. textComp.text = text;
  21. GameObject.DontDestroyOnLoad(o);
  22. Sequence seq = DOTween.Sequence();
  23. seq.PrependInterval(3);
  24. seq.AppendCallback(() => {
  25. GameObject.Destroy(o);
  26. });
  27. }
  28. }