TweenAssetGrpupInfo.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 List<Object> allTargets = new List<Object>();
  12. public TweenAssetInfo TweenAssetInfo;
  13. public bool TargetFoldout = true;
  14. public float maxDuration;
  15. public bool isUpdate;
  16. [HideInInspector] public float currTime;
  17. // public List<TweenEntity> allTweenInfo = new List<TweenEntity>();
  18. public void StartPlay()
  19. {
  20. if (TweenAssetInfo == null)
  21. {
  22. return;
  23. }
  24. maxDuration = 0;
  25. for (int i = 0; i < TweenAssetInfo.allTweenInfo.Count; i++)
  26. {
  27. TweenEntity tweenEntity = TweenAssetInfo.allTweenInfo[i];
  28. if (tweenEntity.duration + tweenEntity.delay > maxDuration)
  29. {
  30. maxDuration = tweenEntity.duration + tweenEntity.delay;
  31. }
  32. tweenEntity.Prepare();
  33. tweenEntity.Rest(allTargets[i]);
  34. }
  35. isUpdate = true;
  36. currTime = 0;
  37. }
  38. public void SetMaxTime()
  39. {
  40. maxDuration = 0;
  41. if (TweenAssetInfo == null)
  42. {
  43. return;
  44. }
  45. for (int i = 0; i < TweenAssetInfo.allTweenInfo.Count; i++)
  46. {
  47. TweenEntity tweenEntity = TweenAssetInfo.allTweenInfo[i];
  48. if (tweenEntity.duration + tweenEntity.delay > maxDuration)
  49. {
  50. maxDuration = tweenEntity.duration + tweenEntity.delay;
  51. }
  52. }
  53. }
  54. public void JumpToTime(float t)
  55. {
  56. if (TweenAssetInfo == null)
  57. {
  58. return;
  59. }
  60. for (int i = 0; i < TweenAssetInfo.allTweenInfo.Count; i++)
  61. {
  62. TweenAssetInfo.allTweenInfo[i].Prepare();
  63. // allTweenInfo[i].Rest();
  64. }
  65. PlayTween(t, true);
  66. }
  67. public void PlayTween(float t, bool isFallBack)
  68. {
  69. if (TweenAssetInfo == null)
  70. {
  71. return;
  72. }
  73. for (int i = 0; i < TweenAssetInfo.allTweenInfo.Count; i++)
  74. {
  75. TweenAssetInfo.allTweenInfo[i].Play(allTargets[i], t, isFallBack);
  76. }
  77. }
  78. }
  79. }