/// <summary> /// 放回一个 /// </summary> public virtual void back(T obj) { if (obj == null) { Ctrl.throwError("对象池添加空对象"); return; } if (!_enable || _queue.size() >= _maxSize) { if (_releaseFunc != null) { _releaseFunc(obj); } return; } if (_needClear) { if (obj is IPoolObject) { ((IPoolObject)obj).clear(); } } if (ShineSetting.openCheck) { if (_checkSet.contains(obj)) { Ctrl.print("上次调用", _callStackDic.get(obj)); Ctrl.throwError("对象池重复添加!", obj); return; } _checkSet.add(obj); string stackTrace = Ctrl.getStackTrace(); stackTrace = stackTrace.Replace("\n", " "); _callStackDic.put(obj, stackTrace); } _queue.add(obj); }
public void unloadOne(GameObject obj) { --_refCount; if (obj != null) { obj.transform.SetParent(_poolRootTrans); ResourceNode node = new ResourceNode(); node.obj = obj; node.inTime = Ctrl.getFixedTimer(); _queue.add(node); ++_parent.num; } //直接-1 if (_refCount == 0 && _queue.isEmpty()) { LoadControl.unloadOne(id); } }