Exemplo n.º 1
0
    void Instantiate(GameObject surfaces, ObjectPoolTypeVariable typeVariable = null, float zOffset = 0)
    {
        ObjectPoolTypeVariable currentTypeVariable = typeVariable == null?GetRandomObjectPoolTypeVariable() : typeVariable;

        GameObject pooledObject = objectPoolController.GetPooledObject(currentTypeVariable);

        if (randomPositionInsideSurface)
        {
            pooledObject.transform.position = GetRandomPosition(surfaces);
        }
        else
        {
            pooledObject.transform.position = transform.position;
        }
        pooledObject.transform.position += new Vector3(0, 0, zOffset);
        InvokeOnSpawn(pooledObject);
        pooledObject.SetActive(true);
    }