Prefabs
When the scene begins to fill up with objects, some of these objects might become complex. By complex, I mean with a lot of components and children. If we need to use many of them in the game and maybe change all of them at once, Unity offers the possibility to create a Prefab.
As the name suggests, it is an object already assembled with all the necessary components and ready to be placed in the scene. The advantage is the possibility to reuse it often and to change all its instances quickly.
Note
If an object in the scene is a Prefab, its name in the Hierarchy panel is blue. If the name is red, instead, this means that there are some references missing.
To keep our project organized, let's create a folder named Prefabs
, if we haven't done so yet. Inside the folder, right-click and then select Create/Prefab
. You can name it as you want, but for this book, let's stick with Pink_Sprinkle_Projectile_Prefab
.
We already have the sprinkle in the scene, so from the Hierarchy panel, drag it into...