TweenPlayFx.cs 1.4 KB

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