Exemple #1
0
        public void SetSize(int size)
        {
            int tooMany = _entries.Count - size;

            if (tooMany > 0)
            {
                int delete = _entries.Count - tooMany;
                for (int i = _entries.Count - 1; i >= delete; i--)
                {
                    _entries[i].Element.CheapDisable();
                    _pool.Release(_entries[i]);
                }
                _entries.RemoveRange(delete, tooMany);
            }

            int tooFew = size - _entries.Count;

            if (tooFew > 0)
            {
                for (int i = 0; i < tooFew; i++)
                {
                    var entry = _pool.Instantiate();
                    entry.Element.CheapEnable();
                    entry.Element.BringToFront();
                    _entries.Add(entry);
                }
            }
        }
 public void Release(T value)
 {
     if (_onRelease != null)
     {
         _onRelease(value);
     }
     _parent.Release(value);
 }
Exemple #3
0
        public void SetSize(int size)
        {
            int tooMany = _entries.Count - size;

            if (tooMany > 0)
            {
                int delete = _entries.Count - tooMany;
                for (int i = _entries.Count - 1; i >= delete; i--)
                {
                    _pool.Release(_entries[i]);
                }
                _entries.RemoveRange(delete, tooMany);
            }

            int tooFew = size - _entries.Count;

            if (tooFew > 0)
            {
                for (int i = 0; i < tooFew; i++)
                {
                    _entries.Add(_pool.Instantiate());
                }
            }
        }