TweenTextMeshProUGUI.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using System.Collections.Generic;
  2. using UnityEngine;
  3. namespace Core.UI.UTool.UITween
  4. {
  5. public class TweenTextMeshProUGUI: TweenBasic
  6. {
  7. public enum TweenTextMeshProUGUIType
  8. {
  9. Al,
  10. }
  11. public class TweenTextMeshProUGUIInfo
  12. {
  13. public TweenRectTransformType TweenRectTransformType;
  14. public TweenLerpType TweenLerpType;
  15. public Vector3 Start;
  16. public Vector3 End;
  17. public AnimationCurve startX=new AnimationCurve();
  18. public AnimationCurve startY=new AnimationCurve();
  19. public AnimationCurve startZ=new AnimationCurve();
  20. }
  21. // public RectTransform RectTransform;
  22. public List<TweenRectTransformInfo> TweenRectTransformInfos = new List<TweenRectTransformInfo>();
  23. public RectTransform GetRectTransform(Object RectTransform)
  24. {
  25. RectTransform rectTransform = RectTransform as RectTransform;
  26. if (rectTransform == null)
  27. {
  28. GameObject gameObject = RectTransform as GameObject;
  29. if (gameObject != null)
  30. {
  31. rectTransform = gameObject.GetComponent<RectTransform>();
  32. }
  33. }
  34. return rectTransform;
  35. }
  36. protected override void ProPlay(Object RectTransform, float allTime)
  37. {
  38. RectTransform rectTransform = GetRectTransform(RectTransform);
  39. if (rectTransform == null)
  40. {
  41. return;
  42. }
  43. float t = _addTime * allTime;
  44. if (t > 1)
  45. {
  46. t = 1;
  47. }
  48. for (int i = 0; i < TweenRectTransformInfos.Count; i++)
  49. {
  50. TweenRectTransformInfos[i].Play(rectTransform, t);
  51. }
  52. }
  53. protected override void ProRest(Object RectTransform)
  54. {
  55. RectTransform rectTransform = GetRectTransform(RectTransform);
  56. if (rectTransform == null)
  57. {
  58. return;
  59. }
  60. for (int i = 0; i < TweenRectTransformInfos.Count; i++)
  61. {
  62. TweenRectTransformInfos[i].Rest(rectTransform);
  63. }
  64. }
  65. }
  66. }