In this lesson, you will learn how to customize individual Prefab instances while keeping them synchronized with their original source asset.
The Power of Overrides
Up to this point, we have used Prefabs as static templates. However, game design often requires variations—perhaps you have a Tree Prefab, but you need one specific instance to be slightly larger or have a different tint. Instead of creating a new Prefab for every tiny variation, we use Prefab Overrides.
An override occurs when you change a property on an instance that differs from the original Prefab asset. Unity tracks these changes locally for that instance.
Managing Changes
When you select an instance of a Prefab in your Hierarchy, the Inspector highlights overridden properties in bold. You have two primary ways to manage these:
- Reverting: If you decide an instance looks "wrong," you can click the bold property label and select Revert. This snaps the value back to the source Prefab’s settings.
- Applying: If you realize your "override" is actually a great design improvement that should exist on all instances, you can click the Overrides button at the top of the Inspector and select Apply All. This pushes your local instance changes back into the source asset, updating every other instance in your project instantly.
Practical Example
Imagine you have a Coin Prefab with a SpinSpeed variable set to 5. You drag three coins into your scene.
- To make one coin move faster, you change its
SpinSpeedto10directly in the Inspector. - The
10appears in bold, indicating an Instance Override. - If you decide this speed is better for all coins, clicking Overrides > Apply All updates the base
Coinasset, and every coin in your game will now inherit the speed of10.
By mastering overrides, you maintain a "single source of truth" while allowing for the granular adjustments necessary for complex level design.
Key Takeaway: Prefab overrides allow you to safely customize individual instances, providing the flexibility to iterate on unique object behaviors while retaining the ability to sync those improvements back to the master asset.