public GameObject[ ] TilePrefab;
public GameObject DoorTilePrefab;
public GameObject currentTile;
public int e;
GameObject prefab = null;
int randomIndex;
void Start ()
{
for (int i = 0; i < e; i++)
{
if (i == e - 1) //check if it is the last tile to spawn
{
SpawnTile(true); //if so spawn a doorTilePrefab instead of a regular prefab
}
else
{
SpawnTile(false); //spawn regular prefab
}
}
}
public void SpawnTile(bool isDoor)
{
randomIndex = Random.Range(0, 2);
prefab = null;
if (isDoor)
{
prefab = DoorTilePrefab;
}
else
{
prefab = TilePrefab[randomIndex];
}
//Save the locations of all random objects
currentTile =(GameObject)Instantiate (prefab, currentTile.transform.GetChild (0).transform.GetChild (randomIndex).position, Quaternion.identity);
}
public void ButtonLoad ()
{
// Retrieve the locations of all random objects
}
}