Prefabs
In the previous example, we created lots of copies of our enemy around the scene, but in doing so, we have created a new problem. Let's imagine we need to change our enemy and add a Rigidbody component to it, but because we have several copies of the same object, we need to take them one by one and add the same component to all of them. Maybe later we will need to change the mass of each enemy, so again, we will need to go over each one of the enemies and make the change, and here we can start to see a pattern. One solution could be to select all the enemies using the Ctrl key (Command on a Mac) and modify all of them at once, but that solution won't be of any use if we have enemy copies in other scenes. So, here is where Prefabs come in.
In this section, we will cover the following concepts related to prefabs:
- Creating Prefabs
- Prefab-instance relationships
- Prefab variants
Let's start by discussing how to create and use prefabs.