public void GetNew(string key, Action <GameObject> action) // , uint num = defaultNum) { GameObject obj = null; if (!dic.ContainsKey(key)) { PoolBase pool = new PoolBase(key, defaultNum); dic.Add(key, pool); obj = pool.Get(); } else { obj = dic [key].Get(); } if (obj == null) { AEResources.LoadSingle(key, (obj1) => { obj = obj1 as GameObject; GameObject go = GameObject.Instantiate(obj); action(go); }); } else { action(obj); } }
public void Create(PoolBase _pool, int _index) { pool = _pool; index = _index; isActive = true; Start(); }
//清空缓存池 public void clearObjectPool(string poolName) { PoolBase pool = getPoolByPoolName(poolName); pool.CleanAll(); poolsDict.Remove(poolName); }
//回收缓存池节点 public void recycleObject(GameObject obj) { string name = obj.name; PoolBase pool = getPoolByPoolName(name); pool.Despawn(obj); }
public void Remove(string name) { if (!_pooldic.ContainsKey(name)) { Debug.LogError("[POOL]:" + name + " is not exist"); return; } PoolBase pool = _pooldic[name]; pool.Clear(); _pooldic.Remove(name); }
public PoolBase Create(string name, GameObject prefab, int initnum) { if (_pooldic.ContainsKey(name)) { Debug.LogError("[POOL]:" + name + " is exist"); return(_pooldic[name]); } GameObject obj = new GameObject(); PoolBase pool = obj.AddComponent <PoolBase>(); pool.Init(name, _trans, prefab, initnum); _pooldic.Add(name, pool); return(pool); }
public override void Setup(params MonoBehaviour[] args) { base.Setup(args); PoolBase projectilesPool = null; foreach (MonoBehaviour arg in args) { if (projectilesPool == null && arg is PoolBase) { projectilesPool = (PoolBase)arg; } } foreach (WeaponBase weapon in weapons) { var rangeWeapon = (WeaponRange)weapon; rangeWeapon.Setup(projectilesPool); } }
/// Used from Pool declaration public void Initialize(PoolBase parentPool) { ParentPool = parentPool; SearchInterfaces(); }
void IClientPoolable.OnInstanceCreated(PoolBase pool) { _pool = pool; }
protected virtual void OnInsoectorInfoGUI(PoolBase pool) { EditorGUILayout.LabelField($"Auto Expand:{ pool.AutoExpand}"); }
/// <summary> /// /// </summary> /// <param name="pool"></param> void IClientPoolable.OnInstanceCreated(PoolBase pool) { _pool = pool; _go = gameObject; }
public virtual void Reset() { pool = null; index = -1; isActive = false; }
void InitPool() { mCheckPool = new PoolBase <Check>(m_CheckSample, m_CheckPool); mChessPool = new PoolBase <Chess>(m_ChessSample, m_ChessPool); }
public void Remove(PoolBase pool) { Remove(pool.Name); }
//获得缓存池节点 public GameObject spawnObject(string poolName) { PoolBase pool = getPoolByPoolName(poolName); return(pool.Spawn()); }