123456789101112131415161718192021222324252627282930313233343536 |
- using FairyGUI;
- using System.Collections.Generic;
- namespace GFGGame
- {
- public static class EffectUIPool
- {
- private static List<EffectUI> effectUIs = new List<EffectUI>();
- public static EffectUI CreateEffectUI(GGraph holder, string uiName, string resName, float scale = 100)
- {
- EffectUI effectUI;
- if (effectUIs.Count > 0)
- {
- int lastIndex = effectUIs.Count - 1;
- effectUI = effectUIs[lastIndex];
- effectUIs.RemoveAt(lastIndex);
- }
- else
- {
- effectUI = new EffectUI();
- }
- effectUI.Reset(holder, uiName, resName, scale);
- return effectUI;
- }
- public static void Recycle(EffectUI effect)
- {
- if (effect == null) return;
- effect.Release();
- if (effectUIs.Contains(effect)) return;
- effectUIs.Add(effect);
- }
- }
- }
|