I am following a tetris tutorial when it called for an array of prefabs as a part of the spawner object. The spawner would randomly create the shapes, such as the I shape, the T shape, etc. These shapes are prefabs.
public class Spawner : MonoBehaviour {
public GameObject[] blocks;
//...
}
This setup would make a custom field in the Inspector, where I can put in all the shapes that could spawn. However, this got me thinking, what if I have 1000 shapes? Surely there's a better way than filling in 1000 prefabs? Can I initialize the array without the Inspector?
Thank you for your time.
Using the Inspector this is actually pretty easy:
Select your 1000 prefabs -> drag&drop them all onto the name of the list/array in the Inspector
=> they all get added as new elements to the list/array (afaik in the order they were selected) ... what could be easier than that? ;)