If I create a public gameobject and then drag the prefab into the inspector slot on the script it works fine when I instantiate it.
However what I want to do is have that gameobject change depending on which button is clicked in the interface. As a simple example, I have created blue, green and red cubes. Depending on which color button is clicked in the GUI, then when the user clicks on screen I want that corresponding cube to be instantiated.
While the simple example has 3 items, in reality I have about 100 so while I could create 100 public variables and drag all the prefabs into each corresponding slot I don’t think this would be the recommend way of doing this.
Any advice, recommendations or tutorials you can point me towards?
You don’t have to drag in 100 objects. Multi-select in the project view and drag once to the slot.
Also, if you have that many objects you’re probably better off with a data-driven approach rather than creating 100 prefabs. You could use a ScriptableObject with the base prefab, then have 100 entries that specify what is different about the prefab, color and so forth.
The prefabs are all (at their core) Blender FBX files. But unfortunately not just one shape with different materials. There is a bit of duplication but that only accounts for about 25% of the objects, the rest are all unique from each other.