Example #1
0
    public GameObject Spawn(string tag, Vector3 pos, Quaternion rot)
    {
        if (!poolDictionary.ContainsKey(tag))
        {
            return(null);
        }

        GameObject obj = poolDictionary[tag].Dequeue();

        obj.SetActive(true);
        poolDictionary[tag].Enqueue(obj);

        obj.transform.position = pos;
        obj.transform.rotation = rot;

        IPoolable p = obj.GetComponent <IPoolable>();

        if (p != null)
        {
            p.Activate();
        }

        return(obj);
    }