private void EditorUpdate() { if (EditorPoolProfiler.isDirty) { EditorPoolProfiler.CleanDirty(); this.Repaint(); } }
/// <summary> /// 在Pool中预先生成一定数量的对象 /// </summary> public void PreAllocate(int count) { for (var i = 0; i < count; i++) { EditorPoolProfiler.TrackAllocate(this); Release(new T()); } }
public virtual T Request() { ThrowExceptionIfEmpty(); T ret = _cache.Pop(); _cacheSet.Remove(ret); EditorPoolProfiler.TrackRequest(this); return(ret); }
private T Load(Transform parent) { if (!prefab) { return(null); } EditorPoolProfiler.TrackAllocate(this); return(Object.Instantiate <GameObject>(prefab, parent).GetComponent <T>()); }
private T Load(Transform parent, Vector3 position, Quaternion rotation) { if (!prefab) { return(null); } EditorPoolProfiler.TrackAllocate(this); return(Object.Instantiate <GameObject>(prefab, position, rotation, parent).GetComponent <T>()); }
protected void Clear() { while (_cache.Count > 0) { var item = _cache.Pop(); _cacheSet.Remove(item); EditorPoolProfiler.TrackRequest(this); OnClearItem(item); } }
private T Load() { if (!prefab) { return(null); } var ret = Object.Instantiate <GameObject>(prefab).GetComponent <T>(); EditorPoolProfiler.TrackAllocate(this); return(ret); }
public override T Request() { if (this.isEmpty) { EditorPoolProfiler.TrackAllocate(this); return(new T()); } else { return(base.Request()); } }
private void OnGUI() { DrawToolButton(); EditorPoolProfiler.ListPoolStatics(_statics); var headerRect = EditorGUILayout.GetControlRect(GUILayout.Height(15)); DrawHeader(headerRect); foreach (var s in _statics) { var rect = EditorGUILayout.GetControlRect(GUILayout.Height(15)); DrawStaticsItem(rect, s); } }
public virtual void Release(T item) { if (item == null) { throw new System.ArgumentNullException("item"); } if (_cacheSet.Contains(item)) { throw new PoolException(PoolExceptionType.DuplicateRelease); } _cache.Push(item); _cacheSet.Add(item); EditorPoolProfiler.TrackRelease(this); }
private T AllocateItem() { EditorPoolProfiler.TrackAllocate(this); return(_allocFunc()); }