Put Prefabs in to an GameObject Array

Dear people,

in my scene I have several instances of a prefab, alread placed as I needed, everything fine.

Now, I want to write a script, where I can put them all together (totally 22 instances of the prefab) into a GameObject Array or List. But how do I bring them into the script?

If I’m using

GameObject Mandal= Instantiate(prefab, new Vector3((float)i, 1, 0), Quaternion.identity) as GameObject;
Mandal.transform.localScale = Vector3.one;
MandalArray[i]=Mandal;

I just get Mandal(clones) and not the once I placed into the scene.

How can I bring the instances of a prefab together (within Start())?
I’m using C#

You can tag them and use GameObject.FindGameObjectsWithTag.

Done! By using tags!

public GameObject[] MandalArray ;
....
void Start(){
         MandalArray=GameObject.FindGameObjectsWithTag("Mandal");
....

If you have any other proposals, however, please let me know!

Thanks, it seemed I got it in the same minute :wink:

Thanks - I was searching for similar and this helped me out :slight_smile: