예제 #1
0
    public GameObject SpawnObjectByType(eObjectType type, Transform parent, ePoolName poolName)
    {
        GameObject objSpawn = GetObjectByType(type);
        SpawnPool  pool     = PoolManager.Pools[poolName.ToString()];

        if (pool != null && objSpawn != null)
        {
            return(pool.Spawn(objSpawn, parent).gameObject);
        }
#if UNITY_EDITOR
        Debug.Log("khong spawn duoc!");
#endif
        return(null);
    }
예제 #2
0
    public void DespawnObject(GameObject obj, ePoolName poolName)
    {
        if (PoolManager.Pools.ContainsKey(poolName.ToString()))
        {
            SpawnPool pool = PoolManager.Pools[poolName.ToString()];
            if (pool.IsSpawned(obj.transform))
            {
                pool.Despawn(obj.transform);
            }
        }
        else
        {
#if UNITY_EDITOR
            Debug.Log(poolName + "khong co trong pool");
#endif
        }
    }
예제 #3
0
    public void DespawnObjectAfter(GameObject obj, ePoolName poolName, float time)
    {
        if (PoolManager.Pools.ContainsKey(poolName.ToString()))
        {
            SpawnPool pool = PoolManager.Pools[poolName.ToString()];
            pool.Despawn(obj.transform, time);
            //if (pool.IsSpawned(obj.transform))
            //{
            //    Debug.Log("despawm");
            //    pool.Despawn(obj.transform,time);
            //}
        }
        else
        {
#if UNITY_EDITOR
            Debug.Log(poolName + "khong co trong pool");
#endif
        }
    }