Example #1
0
 private void EditorUpdate()
 {
     if (EditorPoolProfiler.isDirty)
     {
         EditorPoolProfiler.CleanDirty();
         this.Repaint();
     }
 }
Example #2
0
 /// <summary>
 /// 在Pool中预先生成一定数量的对象
 /// </summary>
 public void PreAllocate(int count)
 {
     for (var i = 0; i < count; i++)
     {
         EditorPoolProfiler.TrackAllocate(this);
         Release(new T());
     }
 }
Example #3
0
        public virtual T Request()
        {
            ThrowExceptionIfEmpty();
            T ret = _cache.Pop();

            _cacheSet.Remove(ret);
            EditorPoolProfiler.TrackRequest(this);
            return(ret);
        }
Example #4
0
 private T Load(Transform parent)
 {
     if (!prefab)
     {
         return(null);
     }
     EditorPoolProfiler.TrackAllocate(this);
     return(Object.Instantiate <GameObject>(prefab, parent).GetComponent <T>());
 }
Example #5
0
 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>());
 }
Example #6
0
 protected void Clear()
 {
     while (_cache.Count > 0)
     {
         var item = _cache.Pop();
         _cacheSet.Remove(item);
         EditorPoolProfiler.TrackRequest(this);
         OnClearItem(item);
     }
 }
Example #7
0
        private T Load()
        {
            if (!prefab)
            {
                return(null);
            }
            var ret = Object.Instantiate <GameObject>(prefab).GetComponent <T>();

            EditorPoolProfiler.TrackAllocate(this);
            return(ret);
        }
Example #8
0
 public override T Request()
 {
     if (this.isEmpty)
     {
         EditorPoolProfiler.TrackAllocate(this);
         return(new T());
     }
     else
     {
         return(base.Request());
     }
 }
Example #9
0
        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);
            }
        }
Example #10
0
 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);
 }
Example #11
0
 private T AllocateItem()
 {
     EditorPoolProfiler.TrackAllocate(this);
     return(_allocFunc());
 }