EffectUIPool.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using FairyGUI;
  2. using System.Collections.Generic;
  3. using System;
  4. namespace GFGGame
  5. {
  6. public static class EffectUIPool
  7. {
  8. private static List<EffectUI> effectUIs = new List<EffectUI>();
  9. public static EffectUI CreateEffectUI(GGraph holder, string uiName, string resName, float scale = 100,
  10. Action onComplete = null)
  11. {
  12. EffectUI effectUI;
  13. if (effectUIs.Count > 0)
  14. {
  15. int lastIndex = effectUIs.Count - 1;
  16. effectUI = effectUIs[lastIndex];
  17. effectUIs.RemoveAt(lastIndex);
  18. }
  19. else
  20. {
  21. effectUI = new EffectUI();
  22. }
  23. effectUI.Reset(holder, uiName, resName, scale, EffectUIType.UI, onComplete);
  24. return effectUI;
  25. }
  26. public static void Recycle(EffectUI effect)
  27. {
  28. if (effect == null) return;
  29. effect.Release();
  30. if (effectUIs.Contains(effect)) return;
  31. effectUIs.Add(effect);
  32. }
  33. }
  34. }