How to Sequentially Instantiate Prefabs from Game Objects in an Array?

Hey everybody,

I have an array that instantiates prefabs when i click the mouse button. It works fine.

The problem is after all the prefabs have been instantiated, say 10 for an example. I need to go back to the first prefab that was instantiated and instantiate another prefab on it.

I need to go through all prefabs and sequentially until all 10 have the new prefab instantiated on them.

Basically I need to go back to the beginning of the array where i=0 and instantiate prefabs for all 10 of the prefabs that were just made.

How do you go about doing this?


Does this work for you?

GameObject[] instances = new GameObject[10];
int i = 0;

    while  (i < instances.Length)  {
        instances *= Instantiate(whatever);*


i = 0;

while (i < instances.Length) {
OR in one step:
for (int i = 0; i < 10; i++) {
GameObject instance = Instantiate(whatever);
GameObject anotherInstance = Instantiate(whatever else);