Exemplo n.º 1
0
        public Pool(GameObject prefab, int size, PoolTracker tracker)
        {
            var poolable = prefab.GetComponentInChildren <IPoolable>(true);

            if (poolable == null)
            {
                Debug.LogWarning($"No {nameof(IPoolable)} found in {prefab.name} prefab. Make sure one script implements it.");
                return;
            }

            _entries   = new GameObject[size];
            _available = new Queue <GameObject>(size);

            _mainRoot  = tracker.FindMainRoot(this);
            _localRoot = tracker.FindLocalRoot(this, prefab);
            _id        = prefab.name;
            Create(prefab, size);
        }
Exemplo n.º 2
0
 private PoolSystem()
 {
     _pools       = new Dictionary <string, Pool>();
     _poolTracker = new PoolTracker();
 }