Unity Prefabs
2 min readMay 9, 2021
A Prefab in Unity is a template that allows us to store a GameObject, its configuration, property values and child object as a reusable asset, then you can create a new instance of the Prefab in the Scene.
In this example we gonna show how to create a simple collectible prefab for our game:
- Create a new sphere in the scene:
- Create a material to modify the color and change the size:
- Create a “Prefab” folder in the project window and drag the object from the hierarchy to the Prefab folder (the object in hierarchy gonna change the color to blue, that mean it is a prefab now):
Good to go, you can drag more collectible prefabs from your prefab folder to the scene:
All of these objects share the same configuration, there are two ways to make changes in all prefab instances:
- Doble click the prefab in the project window, the editor gonna open a scene dedicated only for this prefab, you can make the changes and save:
- Make changes in one instance and select the option “Overrides” in the inspector and select “Apply All”: