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

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

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