How To Create An Array of instantiated objects? [Solved!]

Im instanstiating Some Random prefabs, and I need to store those prfabs in an array, how could i do that?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Random = UnityEngine.Random;

public class MasterSpawner : MonoBehaviour
{
    public Image[] Pannels;
    public GameObject[] Plannets;
    GameObject[] PlannetsSave;
    bool UsedOnce = false;
    public void RandomizeAndInstanciate()
    {
        if (!UsedOnce)
        {
            UsedOnce = true;
            foreach (Image i in Pannels)
            {
                int R = Random.Range(1, Plannets.Length);
                GameObject GO = Plannets[R];
                Instantiate(GO, i.transform.position, i.transform.rotation);

            }
        }

    }

}

Instantiate returns a gameobject. I would just add that to a list rather than an array as it looks like the size would be variable.

1 Like

oh That Actually could be a way to do it, Il go try it out! thanks!

edit: Ive messed about with the code and got to this script after some time, Ive added these lines to my codes:
/// At the top
public List PlannetsSave = new List();
/// in the “Foreach” loop.
GameObject GOB = Instantiate(GO, i.transform.position, i.transform.rotation);
PlannetsSave.Add(GOB);

Thanks WarmedxMints!