Today I was adding some new GameObjects(GOs) to my game scene, some of those GOs were Item Pickups, some small components that have a trigger to identify that the player has found them, a component that implements an interface to identify that the player found something that can be picked up, a property for a ScriptableObject that represents an item and a Sprite to show the look of the object inside the scene.
But after placing the Item Pickup I ran into a small problem, the item and the environment have the same color pallete, giving the chance for the player to completely miss it.
Not difficult to fix this, just add another trigger and a script that kicks in when the player character is close enough to the item and it flashes, that would easily do the trick.
Fortunately I noticed this issue quite soon, so right away I created a prefab from this GO and added it to my asset collection.
What is a prefab? It’s a GO that gets stored in your project folder and whenever you want to use it again in another part of the scene, or even in another scenes, you simply drag it from your project folder into the scene, and done, you have exactly the same GO you previously built.
But this is only one of the few advantages of using prefabs, if tomorrow I decide that all my Pickable Objects will have an animation after being picked up I can add the required components for this in my prefab, and instantly every instantiated prefabs in my scenes will also have this change.
Unfortunately I also needed to make some modifications to other GOs in my scene where I used the poor man’s prefabs, copy paste, which was quite a horror, since for each one of them I had to apply the same changes.
This might seem something trivial when you have 2 or 3 replicated GOs in your scene, the problem is when your team grows and everyone else starts to do this, the next time that a change is required instead of being done in just one place it has to be done in many more.
If a designer that doesn’t know how some components communicate with each other but he needs to add them to the scene having prefabs will make everyone’s life’s easier as well, because he can simply drag and drop the prefab to the scene, and since it’s already assembled the designers work is minimal, and whoever works with the components of that prefab won’t have to be bothered to show the designer how to put each components together.