TipsComp.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using DG.Tweening;
  2. using Plugins.CxShine.page;
  3. using Unity.VisualScripting;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6. namespace UI.Common
  7. {
  8. public class TipsComp : MonoBehaviour
  9. {
  10. public static void ShowTips(string str)
  11. {
  12. Debug.Log(str);
  13. var o = PageManagerComp.singleton.OpenPage("Items/TipsPrefab");
  14. o.GetComponent<TipsComp>()._show(str);
  15. }
  16. public Text TextContent;
  17. public Image Main;
  18. private void Start()
  19. {
  20. }
  21. private void close()
  22. {
  23. if (gameObject.IsDestroyed())
  24. {
  25. return;
  26. }
  27. Destroy(gameObject);
  28. }
  29. private void _show(string testString)
  30. {
  31. TextContent.text = testString;
  32. Invoke(nameof(close), 2f);
  33. var sq = DOTween.Sequence();
  34. // sq.Append(Main.transform.DOLocalMove(
  35. // new Vector3(Main.transform.position.x, Main.transform.position.y + 300, Main.transform.position.z),
  36. // 1f));
  37. // sq.Append(DOTween.Sequence().Append(Main.DOFade(0, 0.5f)).Join(TextContent.DOFade(0, 2f)));
  38. sq.Append(Main.transform.DOMoveY(
  39. Main.transform.position.y + 300,
  40. 1f));
  41. sq.Append(DOTween.Sequence().Append(Main.DOFade(0, 2f)).Join(TextContent.DOFade(0, 2f)));
  42. sq.onComplete += () => { close(); };
  43. sq.Play();
  44. }
  45. }
  46. }