How to save the locations of all random objects and retrieve them in (ButtonLoad).

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

}

}

  1. Use code tags

  2. Describe more clearly what you’re actually trying to accomplish, and in what way your current code doesn’t work.

I want to add code to save the location of all random objects and summoned in void ButtonLoad ?