TweenPlayFx.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using Fort23.UTool;
  2. using UnityEngine;
  3. namespace Core.UI.UTool.UITween
  4. {
  5. [System.Serializable]
  6. public class TweenPlayFx : TweenBasic
  7. {
  8. public GameObject GetCanvasGroup(Object CanvasGroup)
  9. {
  10. GameObject graphic = CanvasGroup as GameObject;
  11. if (graphic == null)
  12. {
  13. GameObject gameObject = CanvasGroup as GameObject;
  14. if (gameObject != null)
  15. {
  16. graphic = gameObject;
  17. }
  18. }
  19. return graphic;
  20. }
  21. protected override void ProPlay(UITweenController uiTweenController, Object CanvasGroup, float allTime)
  22. {
  23. GameObject graphic = GetCanvasGroup(CanvasGroup);
  24. if (graphic == null)
  25. {
  26. return;
  27. }
  28. TweenPlayFxCacheData tweenPlayFxCacheData = uiTweenController.GetCacheData<TweenPlayFxCacheData>(this);
  29. if (!tweenPlayFxCacheData.isPalyFx)
  30. {
  31. ParticleSystem[] particleSystems = graphic.transform.GetComponentsInChildren<ParticleSystem>();
  32. tweenPlayFxCacheData.isPalyFx = true;
  33. for (int i = 0; i < particleSystems.Length; i++)
  34. {
  35. particleSystems[i].Stop();
  36. particleSystems[i].Clear(false);
  37. particleSystems[i].Play(false);
  38. }
  39. }
  40. }
  41. protected override void ProRest(UITweenController uiTweenController, Object CanvasGroup)
  42. {
  43. TweenPlayFxCacheData tweenPlayFxCacheData = uiTweenController.GetCacheData<TweenPlayFxCacheData>(this);
  44. tweenPlayFxCacheData.isPalyFx = false;
  45. }
  46. }
  47. }