TweenAssetGrpupInfo.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. using System.Collections.Generic;
  2. using UnityEngine;
  3. namespace Core.UI.UTool.UITween
  4. {
  5. [System.Serializable]
  6. public class TweenAssetGrpupInfo
  7. {
  8. [HideInInspector] public bool Foldout;
  9. public bool isActive;
  10. public string animName;
  11. public bool isLoop;
  12. public List<Object> allTargets = new List<Object>();
  13. public TweenAssetInfo TweenAssetInfo;
  14. public bool TargetFoldout = true;
  15. public float maxDuration;
  16. public bool isUpdate;
  17. [HideInInspector] public float currTime;
  18. // public List<TweenEntity> allTweenInfo = new List<TweenEntity>();
  19. public void StartPlay()
  20. {
  21. if (TweenAssetInfo == null)
  22. {
  23. return;
  24. }
  25. maxDuration = 0;
  26. for (int i = 0; i < TweenAssetInfo.allTweenInfo.Count; i++)
  27. {
  28. TweenEntity tweenEntity = TweenAssetInfo.allTweenInfo[i];
  29. if (tweenEntity.duration + tweenEntity.delay > maxDuration)
  30. {
  31. maxDuration = tweenEntity.duration + tweenEntity.delay;
  32. }
  33. tweenEntity.Prepare();
  34. tweenEntity.Rest(allTargets[i]);
  35. }
  36. isUpdate = true;
  37. currTime = 0;
  38. }
  39. public void SetMaxTime()
  40. {
  41. maxDuration = 0;
  42. if (TweenAssetInfo == null)
  43. {
  44. return;
  45. }
  46. for (int i = 0; i < TweenAssetInfo.allTweenInfo.Count; i++)
  47. {
  48. TweenEntity tweenEntity = TweenAssetInfo.allTweenInfo[i];
  49. if (tweenEntity.duration + tweenEntity.delay > maxDuration)
  50. {
  51. maxDuration = tweenEntity.duration + tweenEntity.delay;
  52. }
  53. }
  54. }
  55. public void JumpToTime(float t)
  56. {
  57. if (TweenAssetInfo == null)
  58. {
  59. return;
  60. }
  61. for (int i = 0; i < TweenAssetInfo.allTweenInfo.Count; i++)
  62. {
  63. TweenAssetInfo.allTweenInfo[i].Prepare();
  64. // allTweenInfo[i].Rest();
  65. }
  66. PlayTween(t, true);
  67. }
  68. public void PlayTween(float t, bool isFallBack)
  69. {
  70. if (TweenAssetInfo == null)
  71. {
  72. return;
  73. }
  74. if (isLoop)
  75. {
  76. t %= maxDuration;
  77. }
  78. for (int i = 0; i < TweenAssetInfo.allTweenInfo.Count; i++)
  79. {
  80. TweenAssetInfo.allTweenInfo[i].Play(allTargets[i], t, isFallBack);
  81. }
  82. }
  83. }
  84. }