Exemplo n.º 1
0
    public void DestroyAPS(GameObject clone)
    {
        clone.transform.SetParent(transform);
        IPoolable poolable = clone.GetComponent <IPoolable>();

        if (poolable != null)
        {
            poolable.Dispose();
        }
        clone.SetActive(false);
    }
Exemplo n.º 2
0
        private PoolObject CreateGenericPoolObject(GameObject poolObjectType)
        {
            IPoolable poolInterface = poolObjectType.GetComponent <IPoolable>();

            Action onInit = () => { };

            onInit += () => poolObjectType.SetActive(true);
            onInit += () => poolInterface?.Init();

            Action onDispose = () => { };

            onDispose += () => poolInterface?.Dispose();
            onDispose += () => poolObjectType.SetActive(false);

            return(new PoolObject(poolObjectType, onInit, onDispose));
        }
Exemplo n.º 3
0
 private void ObjectDisposing(IPoolable pooledObject, bool alive)
 {
     try {
         lock (this.Busy) {
             this.Busy.Remove(pooledObject);
         }
         if (alive)
         {
             lock (this.Free) {
                 if (!this.Free.Contains(pooledObject))
                 {
                     this.Free.Push(pooledObject);
                 }
             }
         }
         else
         {
             pooledObject.Dispose();
         }
     } catch (Exception e) {
         ExceptionService.Publish(e);
     }
 }
Exemplo n.º 4
0
 private void ObjectDisposing(IPoolable pooledObject, bool alive)
 {
     try {
         lock(this.Busy) {
             this.Busy.Remove(pooledObject);
         }
         if(alive) {
             lock(this.Free) {
                 if(!this.Free.Contains(pooledObject)) {
                     this.Free.Push(pooledObject);
                 }
             }
         } else {
             pooledObject.Dispose();
         }
     } catch(Exception e) {
         ExceptionService.Publish(e);
     }
 }