예제 #1
0
    /// <summary>
    /// Spawns a gameobject.
    /// </summary>
    /// <param name="pos">The position to spawn the gameobject.</param>
    /// <param name="rot">The rotation to spawn the gameobject.</param>
    /// <returns>The spawned gameobject.</returns>
    public GameObject Spawn(Vector3 pos, Quaternion rot)
    {
        GameObject com = null;

        if (DespawnedElements.Count != 0)
        {
            while (com == null && DespawnedElements.Count > 0)
            {
                com = DespawnedElements.Dequeue();
            }
            if (com == null)
            {
                com = Instantiate();
            }
        }
        else
        {
            com = Instantiate();
        }
        com.transform.position           = pos;
        com.transform.transform.rotation = rot;
        ActiveObject.Add(com);
        com.gameObject.SetActive(true);
        if (OnObjectSpawn != null)
        {
            OnObjectSpawn.Invoke(com, this);
        }
        return(com);
    }
예제 #2
0
    public GameObject Spawn(Vector3 pos, Quaternion rot)
    {
        GameObject com = null;

        if (DespawnedElements.Count != 0)
        {
            com = DespawnedElements.Dequeue();
        }
        else
        {
            com = Instantiate();
        }
        com.transform.position           = pos;
        com.transform.transform.rotation = rot;
        ActiveObject.Add(com);
        com.gameObject.SetActive(true);
        return(com);
    }