Lesson 2 - Prefabs, Instances and Overrides

Why a prefab is an asset and not a scene, how one edit reaches fifty copies, and what an override really does - the per-property switch that makes one instance stop listening to its prefab for good.

Subject: Unity Game Engine · 61 slides · code lesson

Open the interactive version of this deck · Homework for this lesson

What this lesson covers

The lesson, slide by slide

1. Prefabs, Instances and Overrides

Title

Unity - Lesson 2

One asset, fifty copies, and the one switch that makes a copy stop listening.

2. What you will be able to do

Objectives

The diagnostic scored this 1 out of 3 - the joint-lowest topic in the report. Every wrong answer came from the same place: not being certain which of two things was being edited.

  1. Say what a prefab is in one sentence, and why it is not a scene
  2. Predict, before clicking, whether an edit will reach one copy or all of them
  3. Recognise an override in the Inspector on sight - the bold label and the blue bar
  4. Explain why an overridden property ignores all future prefab changes, not just the next one
  5. Use Apply and Revert deliberately, knowing what each one rewrites

3. What do you think happens?

Warm-up

Answer from memory before the deck tells you anything.

Discussion prompt

You have 30 enemies in a level, all copies of the same prefab. You want them all to have 50 more health. Describe every way you can think of to do it, and which one you would actually use.

Hint: One of the ways involves clicking 30 times. That one is a trap, and not only because it is slow.

Answer:

The right way: open the prefab asset, change Health, done. Every instance that has not overridden Health picks it up.

The trap: selecting all 30 in the Hierarchy and typing the new value. That works today - and it creates 30 overrides, so the next prefab change reaches none of them.

That second outcome is the whole lesson: the fast fix now is the reason the next fix silently fails.

4. What a prefab is

Section

Part 1

5. A prefab is a saved GameObject, in a file

Concept

Figure (svg): A prefab asset drawn as a mould in the Project window with arrows to five identical instances in a scene

One file, five castings. Edit the file and every casting changes.

A prefab is one GameObject - with all its components, all their values, and all its children - saved as an asset in the Project window.

Prefab — An asset holding one saved GameObject tree. It lives on disk, belongs to no scene, and acts as the master copy for every instance of it.

Unity Manual - Prefabs Prefabs

6. A mould, not a photograph

Intuition

A photograph of a coin records what one coin looked like. A mould makes coins - and if you file a notch into the mould, every coin cast afterwards has the notch.

A prefab is the mould. The copies in your scene are castings that are still connected to it: change the mould and the existing castings change too, which is more than any real mould can do.

That last part is the whole reason prefabs exist. Without the connection you would just be copy-pasting, and 'change all fifty' would mean changing all fifty.

7. Predict: where does a prefab live?

Prediction

You save Coin.prefab, then close the scene without saving it, and open a completely different scene.

Predict first

What has happened to the prefab?

  • It is gone - it belonged to the scene
  • It is still there in the Project window
  • It exists but is empty until a scene uses it
  • It moved into the new scene automatically

Correct: Still there, unchanged, in the Project window.

Why: A prefab is an asset: a file on disk under Assets. It is not part of any scene, which is exactly what makes it reusable across every scene in the project. Scenes come and go; the asset stays.

8. A prefab is not a scene

Concept

These are two different kinds of asset, and mixing them up leads to looking for a prefab in the Hierarchy or expecting a scene to be reusable.

PrefabScene
holdsone GameObject treemany objects, plus lighting and render settings
fileCoin.prefabLevel1.unity
opened bydouble-click into Prefab Modedouble-click to load it
reusedyes - drop it in any scene, any number of timesno - you load one at a time
has a camera?only if you put one in itusually yes

A useful test: ask 'how many of these can be open at once?'. Any number of prefabs; one scene (plus additively loaded ones, later).

9. Asset or scene object?

Sorting

Sort each item by where it actually lives.

Sort into buckets

Project window, or Hierarchy?

Asset - a file in the Project
Coin.prefab; Level1.unity; PlayerMove.cs; A material you made
Object - lives in the open scene
The blue 'Coin 3' in your Hierarchy; The Main Camera
asset
It is a file under Assets/. It survives closing the scene, can be used by many scenes, and is edited in the Project window or in Prefab Mode.
scene
It appears in the Hierarchy. It exists only while this scene is open and is saved into the .unity file when you save the scene.

10. Making one: the drag that changes everything

Worked example

Build the object once in the scene, then drag it into the Project window. Three things happen at that moment.

  1. A file Coin.prefab appears in the Project window
  2. The object in your Hierarchy turns blue - it is now an instance, not a free-standing object
  3. Its Inspector grows a header with Open / Select / Overrides
// the same gesture in code, from an editor script
GameObject temp = GameObject.CreatePrimitive(PrimitiveType.Cylinder);
temp.AddComponent<CoinSpin>();
GameObject asset = PrefabUtility.SaveAsPrefabAsset(
    temp, "Assets/NaruhodoLabs/Prefabs/Coin.prefab");
Object.DestroyImmediate(temp);
before the dragafter the drag
one GameObject in the sceneone asset on disk + one instance in the scene
white name in the Hierarchyblue name in the Hierarchy
deleting it loses the workdeleting the instance keeps the asset
no Inspector headerOpen / Select / Overrides header

11. Why does the Hierarchy name turn blue?

Explain it to yourself

Discussion prompt

The object you dragged did not change. Its components and values are identical. So what is the blue name telling you?

Answer:

That the object now has a link. It is no longer a free-standing GameObject - it is an instance of an asset, and Unity is tracking which of its properties still match that asset.

Blue means 'someone else has an opinion about what I should look like'. That is the whole difference, and it is why the blue objects are the ones that can be overridden.

12. How an edit travels

Section

Part 2

13. Edit the asset, and every instance follows

Concept

Change a value on the prefab asset and every instance that has not overridden that property picks it up immediately - in every scene, saved or not.

There are two ways to edit the asset: double-click it to enter Prefab Mode (the Hierarchy goes dark and shows only the prefab), or select it and edit its Inspector directly.

Unity Manual - Editing a prefab in Prefab Mode Prefab Mode

14. Predict: the edit that goes nowhere

Prediction

Five coins in the scene, all instances of Coin.prefab. You click Coin 1 in the Hierarchy, change its spin speed from 90 to 360, and press Play.

Predict first

What do the five coins do?

  • All five spin at 360
  • Coin 1 spins at 360, the rest at 90
  • All five at 90 - the change was not saved
  • Coin 1 at 360 until you press Play, then all five at 90

Correct: Coin 1 spins at 360, the other four stay at 90.

Why: You edited an instance, not the asset, so you changed exactly one coin - and you created an override on it in the process. This is the 'my prefab edits do not propagate' complaint, seen from the other side: the edit worked perfectly, it just never touched the prefab.

15. Two panes, two meanings

Concept

Where you clicked decides what you edited. This is the single most useful habit in this lesson: before typing a value, look at which window you are in.

you clickedyou are editingwho is affected
the prefab in the Project windowthe assetevery instance, everywhere
Prefab Mode (double-clicked the asset)the assetevery instance, everywhere
an instance in the Hierarchythat one instancethat one instance, and it becomes an override

The Inspector looks nearly identical in all three cases, which is why this is worth checking deliberately until it becomes automatic.

16. Which window were they in?

Discrimination

For each outcome, decide where the person must have been clicking.

Sort into buckets

Sort by which window produced the outcome.

They edited the asset
All 20 enemies got the new material; The change survived deleting every enemy and dragging fresh ones in
They edited one instance
One enemy is a different colour from the rest; The change vanished when they deleted that enemy
asset
The change lives in the file, so it reaches every instance and survives any instance being deleted. Fresh copies come out of the mould already changed.
inst
The change lives on that one object in the scene. Delete the object and the change goes with it; drag in a fresh copy and it comes out of the mould unchanged.

17. Editing the asset, in code

Worked example

The lab does this from a menu item so you can watch five coins change at once. LoadPrefabContents opens the asset in an invisible scene of its own.

// Naruhodo Labs → Lesson 02 → 2 · Edit the PREFAB
GameObject root = PrefabUtility.LoadPrefabContents(PrefabPath);
root.GetComponent<CoinSpin>().degreesPerSecond = 360f;
PrefabUtility.SaveAsPrefabAsset(root, PrefabPath);
PrefabUtility.UnloadPrefabContents(root);

Open, edit, save, unload

Why: Editing the asset's components directly also works, but this is the API pair Unity guarantees: what you loaded is a real scene tree, so every normal call works on it.

coinspin beforespin afterwhy
Coin 190360follows the prefab
Coin 290360follows the prefab
Coin 390360follows the prefab (not overridden yet)
Coin 490360follows the prefab
Coin 590360follows the prefab

Five objects changed and you touched one file. That is the payoff, and everything else in this lesson is about not accidentally opting out of it.

18. Trap: editing the instance to change 'the prefab'

Trap

The trap

Coin 3 is in front of me in the Hierarchy. I will just change it here - it is the same coin.

Hierarchy:  Coin 3   ->  Inspector  ->  Degrees Per Second: 15
result:     Coin 3 spins slowly. Coins 1, 2, 4, 5 unchanged.
            Coin 3 now has an OVERRIDE on that property.
what you think you didwhat you actually did
changed the coin designchanged one coin
a one-off tweaka permanent opt-out for that property
nothing to undoan override you now have to Revert

The fix

Decide first: is this true of all coins, or just this one? All coins means the asset. Just this one means the instance, deliberately.

Project:  double-click Coin.prefab  ->  Prefab Mode  ->  Degrees Per Second: 15
result:   all five coins spin slowly.
          no overrides created anywhere.

The Inspector tells you which one you are in: in Prefab Mode the Hierarchy is dark and shows only the prefab, and the breadcrumb at the top reads Coin.

Unity Manual - Editing a prefab via its instances Editing a prefab via its instances

19. Overrides: the link that gets cut

Section

Part 3

20. An override is per property, per instance

Concept

Figure (svg): Diagram of a property flowing from prefab to instance, with one instance overriding it and no longer receiving updates

An override cuts the link for one property on one instance - not for the whole object, and not just once.

When you change a value on an instance, that instance stops taking that one property from the prefab. Everything else on it keeps following the asset as before.

Override — A value stored on the instance that replaces what the prefab says for that one property. The instance ignores all future prefab changes to that property.

Unity Manual - Editing a prefab via its instances

21. How to see one

Concept

Unity marks overrides in three places. Learn all three, because the first one you notice is usually the smallest.

If you are ever unsure whether you are looking at a prefab value or an override, open the Overrides dropdown. An empty list means this instance is following the asset on everything.

22. Predict: the second prefab edit

Prediction

Coin 3 has an override: spin = 15. The prefab is at 360. Now someone edits the prefab and sets it to 45.

Predict first

What does Coin 3 do?

  • 45 - the prefab wins, it is the master
  • 15 - the override still holds
  • 15 the first time, then 45 on the next change
  • It throws a conflict warning in the Console

Correct: 15. The override holds, and holds against every future change.

Why: This is the part the diagnostic caught. An override is not 'the instance wins this round' - it is 'this instance no longer takes that property from the prefab'. Until you Revert it, no prefab edit to that property will ever reach this instance again.

23. Watch what stays constant

Invariant

Four states of the same coin. One row never changes once it is set - find it.

Step through it

Which cell stops responding, and at which frame?

  1. Everyone following.
  2. One asset edit, everyone moves.
  3. One instance overridden.
  4. Another asset edit - and the overridden coin is deaf to it.

The override is sticky. That stickiness is the feature (a boss enemy that keeps its own health) and the bug (thirty enemies you edited in bulk last week).

24. Read the override report

Error analysis

This is real output from the lab's step 4. One line explains a bug someone will spend an hour on.

Annotate

  • Following the asset on everything. A future prefab edit reaches this coin.
  • The override, named by the exact property path. Only degreesPerSecond is overridden - this coin still follows the prefab on mass, scale, materials and everything else.
  • The 'effective' value is what the game will actually use. When it differs from the prefab, an override is the only reason.

Notice what is not listed: position. Every instance has its own position, and Unity treats position, rotation and name as expected differences rather than overrides. Otherwise every object you ever moved would be flagged.

25. Fill in the propagation table

Comparison

Three actions, three questions. Complete it from what you now know.

Comparison matrix

Changes the asset?Changes other instances?Creates an override?
Edit the prefab in Prefab Modeyesyesno
Edit one instance in the Hierarchynonoyes
Apply an instance's overrideyesyesno - it clears it

26. Apply and Revert: the two ways out

Concept

Once an override exists there are exactly two things you can do with it.

Apply
Push the instance's value UP into the asset. Everyone gets it, and the override is cleared.
Revert
Throw the instance's value away. It goes back to listening to the prefab.
you wantuse
this tweak was actually right for all of themApply
this tweak was a mistakeRevert
this tweak is right for this one onlyleave it - that is what an override is for

Apply is the one to be careful with: it rewrites the asset, so it changes every other instance in every other scene at the same time.

27. One override, four options

Elimination

A designer changed the boss enemy's health on the instance in Level 3. Everyone agrees the boss should be tougher than a normal enemy.

Eliminate the wrong options

What should happen to that override?

  • A. Leave it as an override on the boss instance.
  • B. Apply it to the prefab.
  • C. Revert it and set the health in a script at runtime instead.
  • D. Make a duplicate prefab called BossEnemy with its own health.

Survives elimination: A

Why: One deliberate difference on one instance is exactly what an override is for, and the blue bar documents it for the next person. Choice D becomes the right answer as soon as the boss differs in several ways - at that point a prefab variant (a prefab based on another prefab) is the tool, and it is worth looking up once this lesson is solid.

28. Break this claim

Counterexample

Discussion prompt

Someone says: 'If I never touch the Hierarchy, I can never create an override.' Find a way that is false.

Hint: Think about the things every instance has its own copy of.

Answer:

Moving an instance in the Scene view writes its position - and while Unity does not flag position as a normal override, adding a component to an instance, or deleting one from it, absolutely is one and is done by dragging, not typing.

A second answer: PrefabUtility.RecordPrefabInstancePropertyModifications from an editor script creates overrides with no clicking at all. The lab's step 3 does exactly that.

29. Prefabs at runtime

Section

Part 4

30. Instantiate stamps out a copy

Concept

At runtime you cannot drag anything. Instantiate(prefab, position, rotation) is the drag, in code - one call, one new GameObject in the scene.

public class PrefabSpawner : MonoBehaviour
{
    public GameObject coinPrefab;   // drag the ASSET here, not a scene object

    void SpawnOne(Vector3 where)
    {
        GameObject clone = Instantiate(coinPrefab, where, Quaternion.identity);
        clone.name = "Coin (spawned)";
    }
}
expressionwhat it is
coinPrefabthe asset - one object, never changes, id stays the same
Instantiate(coinPrefab, ...)a brand-new GameObject, a copy of the asset
clonethe copy - a different instance id every time
clone.nameeditable per copy; the asset's name is untouched

Unity Scripting API - Object.Instantiate Object.Instantiate

31. Predict: editing a clone at runtime

Prediction

During Play, your code changes a spawned coin's spin to 500.

Predict first

What happens to the prefab asset?

  • It changes to 500 as well
  • Nothing - the asset is untouched
  • It changes but reverts when you stop Play
  • Unity warns you that you are editing an asset at runtime

Correct: Nothing. The asset is untouched.

Why: A runtime clone is a copy in the scene. Writing to its components writes to that copy. The 'instance edit changes the prefab' fear is exactly backwards - editing an instance never writes to the asset unless you deliberately Apply, and Apply is an editor-only action that does not exist at runtime.

32. Spawn four, then stop Play

Worked example

The lab spawns four coins on a timer and prints the instance ids.

GameObject clone = Instantiate(coinPrefab, where, Quaternion.identity);
Debug.Log($"spawned {clone.name} — id {clone.GetInstanceID()}, " +
          $"asset id {coinPrefab.GetInstanceID()}");
spawnclone instance idasset idin the scene after Stop?
1-8422 (example)-7104no
2-8630-7104no
3-8841-7104no
4-9052-7104no

Two facts in one table. The asset id never changes - there is only ever one asset. And nothing spawned at runtime is saved: press Stop and all four vanish, because they were never part of the scene file.

33. Complete the spawner

Fill the middle

Fill the two blanks so this spawns a coin one unit above the spawner.

Fill in the blanks

public class Spawner : MonoBehaviour
Instantiate}(coinPrefab, where, Quaternion.identity);
}
}

Why: Quaternion.identity means no rotation - the identity of the rotation system, the way 0 is for addition. It is the value you want whenever the spawned object should sit unrotated; transform.rotation would instead match the spawner's own facing, which is what a gun firing a bullet wants.

34. Order the spawn

Ranking

Put these in the order they happen when a coin is spawned and then collected.

Put in order

Earliest first.

  1. The prefab asset is saved in the Project
  2. The spawner's coinPrefab field is assigned in the Inspector
  3. Instantiate creates the clone and Awake runs on it
  4. Start runs on the clone
  5. Destroy(clone) is called when the player collects it

Why: The first two happen in the editor, before the game ever runs - which is why a missing prefab reference is a setup mistake rather than a bug in your code. Awake fires during Instantiate itself, so a freshly instantiated object has already woken up by the time Instantiate returns to you.

35. Trap: dragging a scene object into the prefab slot

Trap

The trap

The Inspector slot says GameObject and there is a coin right there in the Hierarchy. Drag it in.

Spawner
  Coin Prefab:  [ Coin 3 (Hierarchy) ]     <- a scene object

Result: it spawns copies of Coin 3, including its OVERRIDE (spin = 15),
        and if Coin 3 is destroyed mid-game the field goes null.

It looks like it works, which is why this one survives to a build.

The fix

Drag from the Project window. The field should hold the asset, which nothing in the scene can destroy.

Spawner
  Coin Prefab:  [ Coin (Project) ]         <- the asset

Result: every spawn is a clean copy of the master, with no instance's
        private overrides baked in.
checkhow
is my reference an asset?prefab.scene.IsValid() is false for an asset
in the Inspectorthe little icon is the prefab's blue box, not a scene object
the lab does thisPrefabSpawner checks it at Start and prints PASS or FAIL

36. What actually counts as an override?

Definition probe

Not every difference between an instance and its prefab is an override. Sort these by whether Unity treats them as one.

Sort into buckets

Override, or an expected per-instance difference?

An override - Unity flags it
You typed a new Health value on the instance; You added an Audio Source to the instance; You deleted the instance's Box Collider
Expected per-instance difference
You dragged the instance to a different position; You renamed the instance to 'Boss'
over
A deliberate difference in the object's makeup or its tuned values. It appears in the Overrides dropdown, and it is what future prefab edits will bypass. Added and removed components count, not just typed values.
expected
Position, rotation and name differ on every instance by design - if Unity flagged these, every object you ever moved would be marked and the dropdown would be useless. Unity calls these default overrides and does not colour them blue.

37. Read the Inspector's four signals

Matching

Unity is telling you the prefab state constantly. These four cues are the whole vocabulary.

Match the pairs

Match each cue to what it means.

  • c1. The object's name is blue in the Hierarchy
  • c2. A property label is bold with a blue bar
  • c3. The header reads 'Missing Prefab'
  • c4. A component row has a small plus badge
  • m1. this object is an instance of some prefab
  • m2. this one property is overridden here
  • m3. the asset it was linked to has been deleted or moved
  • m4. this component was added on the instance only

Why: Three of these are visible without opening a single menu, which is the point: the editor is already answering 'am I about to edit an instance?' before you click. Missing Prefab is the one worth reacting to immediately - the objects still work, but nothing you do to any asset will reach them again.

38. Decode an override report line

Notation

The report prints property paths, not friendly names. They are readable once you know the two conventions.

Annotate

  • A public field on YOUR script keeps its own name. This is the readable case, and the one you will see most.
  • The m_ prefix marks Unity's own serialized fields. m_LocalScale.x is the Scale X box in the Transform - the .x says only one axis was touched.
  • m_IsActive = 0 means the instance was deactivated. Yes: switching an instance off is itself an override, which is how a level can ship with one door disabled.

So a report line is who : which property = what value. When a coin behaves differently from its neighbours, this is the line that says why in one glance.

39. Variants and nesting, in one slide

Concept

Two features you do not need today but should recognise by name, because both replace piles of overrides.

Prefab Variant
A prefab whose parent is another prefab. 'Like Enemy, but tougher' - and it still follows Enemy for everything it does not change.
Nested Prefab
A prefab used inside another prefab. A Turret prefab containing a Barrel prefab; edit Barrel once and every turret updates.
situationthe right tool
one number differs on one objectan override
a whole category differs (bosses)a prefab variant
a part is reused across several prefabsa nested prefab
thirty objects differ the same wayyou have a variant, whether or not you have made one yet

40. Two of these are true about Instantiate

Two truths and a lie

One is false. Rule it out and say what rules it out.

Eliminate the wrong options

Which claim about Instantiate is false?

  • A. The clone keeps every component and value the asset had.
  • B. A clone created at runtime stays in the scene after you press Stop.
  • C. You can Instantiate a scene object, not only a prefab asset.

Survives elimination: B

Why: Nothing created at runtime is written back into the scene file. Play mode runs on a copy of the scene, and stopping throws that copy away - which is also why Inspector tweaks made during Play are lost, and why the editor tints itself while playing.

41. Work backwards from the symptom

Reverse engineer

A teammate reports: 'I changed the enemy prefab's speed and only 8 of the 20 enemies got faster.'

Discussion prompt

What did the other 12 enemies have done to them, when, and by whom? Then say exactly what you would click to fix it.

Hint: The 8 that worked are the normal ones. The 12 are the ones with a history.

Answer:

The 12 have an override on speed, created at some earlier point by someone editing them in the Hierarchy - probably in bulk, probably while balancing.

Fix: select the 12, open Overrides in the Inspector, and Revert the speed override. If their tuned values were the good ones, Apply one of them to the prefab first, then Revert the rest onto it.

Then check whether those 12 are really a category - if they are all the 'elite' enemies, they want a variant rather than twelve overrides.

42. Build it in Unity

Section

Build

43. What you are about to build

Concept

A coin prefab, five instances, one deliberate override, and a report that prints exactly which instance is ignoring which property.

Unlike lesson 1, most of this happens with the game stopped - prefabs are an editor feature, and the interesting moments are all edits.

menu stepwhat it proves
1 · Build scene + Coin prefabone asset, five linked instances
2 · Edit the PREFAB (90 to 360)one edit reaches all five
3 · Override ONE instance (to 15)the blue bar appears on one coin
4 · Report overrideswhich property, on which instance
5 · Edit the PREFAB again (to 45)four follow, the overridden one does not
6a / 6b · Apply / Revertthe two ways to clear an override

44. Plan the experiment

Step zero

Discussion prompt

Before opening Unity: what is the smallest set of steps that proves an override is permanent rather than one-time? Write them in order.

Hint: You need at least two prefab edits, with the override created between them.

Answer:

  1. Make the prefab and two instances
  2. Edit the prefab - both instances change (proves the link works)
  3. Override one instance - only that one changes (proves the edit is local)
  4. Edit the prefab again - and now watch which one moves

Step 4 is the one people skip, and it is the only step that distinguishes 'the override won this round' from 'the link is cut'.

45. Steps 1 and 2: build, then edit the asset

Worked example

Do it by hand first: build a cylinder coin, attach CoinSpin, drag it into Assets/NaruhodoLabs/Prefabs.

public class CoinSpin : MonoBehaviour
{
    public float degreesPerSecond = 90f;
    public float bobHeight = 0.25f;

    void Update()
    {
        transform.Rotate(Vector3.up, degreesPerSecond * Time.deltaTime, Space.World);
    }
}

Time.deltaTime is doing real work on line 8

Why: 90 degrees per SECOND, not per frame. Without it the coin spins at a different speed on every machine - the misconception the diagnostic checked separately.

stepwhere you clickcoins affected
drag Coin into ProjectHierarchy to Projectcreates the asset; the dragged one becomes an instance
drag the asset back in, 4 more timesProject to Hierarchy5 instances
double-click the asset, set 360Prefab Modeall 5

46. Steps 3 and 4: create and read the override

Worked example

Now click Coin 3 in the Hierarchy and set its spin to 15. Then run the report.

// what the report does, per instance
PropertyModification[] mods = PrefabUtility.GetPropertyModifications(coin);
foreach (PropertyModification mod in mods)
{
    if (mod.propertyPath.StartsWith("m_LocalPosition")) continue;  // expected per-instance
    Debug.Log($"{coin.name} overrides {mod.propertyPath} = {mod.value}");
}

Line 5 filters out the 'default overrides'

Why: Position, rotation and name differ on every instance by design. Unity does not colour them blue, and neither does this report.

coinreported overridesspin now
Coin 1none360
Coin 2none360
Coin 3degreesPerSecond = 1515
Coin 4none360
Coin 5none360

47. Commit before step 5

Hypothesis

You are about to edit the prefab from 360 to 45, with Coin 3 overridden at 15.

Predict first

Write down the five values you expect before you click.

  • 45, 45, 15, 45, 45
  • 45, 45, 45, 45, 45
  • 45, 45, 15, 15, 15
  • 360, 360, 15, 360, 360

Correct: 45, 45, 15, 45, 45

Why: Four coins follow the asset and take 45. Coin 3 keeps 15 because its link for that property was cut when you typed a value into the instance. Predicting before clicking is the habit that turns this from a rule you memorised into a model you can use.

48. Where this bites in a real project

Real world

Discussion prompt

Your team has 60 enemies across 4 levels, all from one prefab. Someone spent an afternoon 'balancing' by selecting groups in the Hierarchy and typing new health values. Two weeks later the designer changes the prefab's health and nothing happens. Explain what is wrong and how you would fix all 60.

Answer:

Every enemy they touched now has an override on Health, so the prefab edit reaches none of them.

The fix: select the affected instances, open the Overrides dropdown and Revert the Health override on each - or, if the balanced values were the good ones, pick one and Apply it so the asset carries the new number and the rest can be reverted onto it.

The prevention: balance values in Prefab Mode. If a subset genuinely needs different numbers, that subset wants a prefab variant, not sixty overrides.

49. Say it in two sentences

Explain it

Discussion prompt

Explain to someone who has never used Unity what a prefab is and what an override is - two sentences, no jargon beyond those two words.

Answer:

Model answer: 'A prefab is a saved copy of an object kept in a file, and everything you drop into the level from it stays connected, so changing the file changes all of them.'

'An override is when you change one of those copies directly - that copy keeps your value and stops taking that setting from the file, permanently, until you tell it to go back.'

50. Now break it, on purpose

Concept

Each takes under a minute and kills one wrong belief.

do thiswhat you expectwhat happens
Delete Coin.prefab while five coins are in the scenethe coins vanishthey survive; the header reads Missing Prefab
Ask which scene the prefab is inthe current onenone - it is an asset
Add a Rigidbody in Prefab Modeonly the prefab changesall five coins fall - structure propagates too
Apply Coin 3's overrideonly Coin 3 changesthe asset changes, so all five become 15

51. The procedure: before you type a value

Pattern

Four questions, in order. They take three seconds and prevent the entire category of bug this lesson is about.

  1. Is this object blue? Blue in the Hierarchy means it is a prefab instance, so this edit can create an override.
  2. Should this be true of all of them, or just this one? All of them means go to the asset. Just this one means stay here, deliberately.
  3. If all of them: am I in Prefab Mode? The Hierarchy goes dark and the breadcrumb names the prefab. If it does not, you are still editing an instance.
  4. Afterwards: open the Overrides dropdown. An unexpected entry there is a bug you just made, and it is one click to Revert.

And when a subset needs several differences, stop overriding and make a prefab variant - a prefab whose parent is another prefab. It is the supported way to say 'like that, but'.

52. Check 1: what is a prefab?

Check

Answer before you click.

Check your understanding

Which statement describes a prefab most accurately?

  • A. A saved scene containing one object, which you load when you need it
  • B. An asset holding one saved GameObject tree, used as the master copy for instances in any scene (correct)
  • C. A copy of a GameObject that is no longer connected to the original
  • D. A script that builds an object at runtime

Answer: B

Why: A prefab is a file under Assets holding one GameObject with all its components, values and children. It belongs to no scene, can be used in every scene, and every instance stays linked to it - which is what makes one edit reach fifty objects.

Why A tempts people
The prefab-is-a-scene confusion. A scene holds many objects plus lighting and render settings, and you load one at a time; a prefab holds one object tree and any number can be in use at once.
Why C tempts people
That describes a plain copy-paste, which is exactly what a prefab is not. The link is the entire point.
Why D tempts people
That describes a spawner script that Instantiates a prefab. The prefab is the data it stamps out, not the code.

53. Check 2: the edit that reaches everyone

Check

Five instances in the scene, none of them overridden.

Check your understanding

You want all five coins to spin faster. Which action does that, and only that?

  • A. Select all five in the Hierarchy and type the new value
  • B. Double-click Coin.prefab, change the value in Prefab Mode, exit (correct)
  • C. Change Coin 1 in the Hierarchy, then press Ctrl+S
  • D. Change Coin 1, then use Overrides > Apply All

Answer: B

Why: Editing the asset is the only action that changes all five without leaving overrides behind. Every coin that has not overridden that property picks the new value up immediately, in this scene and every other one.

Why A tempts people
It looks identical today and creates five overrides. The next prefab edit will reach none of them - the exact failure this lesson exists for.
Why C tempts people
Saving the scene saves the instance's private value. The asset is untouched, and Coin 1 now has an override.
Why D tempts people
This does end up with the right numbers, but by the long road: it creates an override and then pushes it into the asset. Apply is for a change you have already made and decided you like, not the first move.

54. One question to sit with

Socratic

Discussion prompt

Unity could have made prefab edits win over instance edits, so the asset always dictated. Why would that be worse?

Answer:

Because every real level needs exceptions: this one door is locked, this one enemy is the boss, this one lamp is broken. Without per-instance overrides you would need a separate prefab for every exception.

The cost of that flexibility is precisely the trap in this lesson: a mechanism that lets you say 'this one is different' cannot also stop you saying it by accident. Hence the blue bar - Unity's attempt to make the exception visible.

55. Check 3: the sticky override

Check

The one the diagnostic missed. Take your time.

Check your understanding

Coin 3's spin was overridden to 15 while the prefab said 360. The prefab is now changed to 45, then later to 120. What does Coin 3 read?

  • A. 45, then 120 - the prefab wins eventually
  • B. 15, then 15 - the override holds against both changes (correct)
  • C. 15, then 120 - an override survives one change only
  • D. 120 - the most recent edit always wins

Answer: B

Why: An override cuts the link for that property permanently. Coin 3 will read 15 through every future prefab change until someone Reverts the override or Applies it. 'Permanent until reverted' is the phrase worth memorising.

Why A tempts people
The prefab does not eventually win. There is no timer and no reconciliation pass - the instance simply stopped taking that property from the asset.
Why C tempts people
This is the most tempting wrong answer: it feels like the override should be spent after it is used once. It is not a one-time value, it is a stored one.
Why D tempts people
Recency does not decide it. Ownership does - and the instance owns that property now.

56. A number worth having a feel for

Estimation

A level has 200 coins from one prefab. You change the prefab's mesh.

Predict first

Roughly how many objects do you have to touch by hand?

  • 200
  • About 20
  • One
  • None - it happens automatically

Correct: One: the asset. Every instance that has not overridden the mesh follows.

Why: The answer being one is the entire economic argument for prefabs, and it is why the override trap matters so much - a project where half the instances are accidentally overridden has quietly lost that property and is back to touching things by hand.

57. What this unlocks

Concept

Almost everything you spawn in a game comes from a prefab: bullets, enemies, pickups, particle effects, UI popups. Lesson 5 is about the call that spawns them.

you now havewhat it enables
an asset with a linkone edit reaches every copy
overridesdeliberate exceptions, visible in the Inspector
Instantiateobjects created while the game runs
the Overrides dropdowna way to audit what a scene has quietly changed

58. Connect it to something you know

Analogy

If you have used styles in a word processor, or a class in CSS, you already have the model.

Match the pairs

Match each Unity idea to its closest cousin.

  • u1. Prefab asset
  • u2. Prefab instance
  • u3. Override
  • u4. Revert
  • o1. a paragraph style definition
  • o2. a paragraph using that style
  • o3. direct formatting applied to one paragraph
  • o4. clear formatting, back to the style

Why: The failure mode is the same too: a document where everyone hand-formatted instead of using styles is a document where changing the style does nothing, which is exactly a project full of accidental overrides. Recognising the pattern means the fix transfers as well as the problem.

59. Draw the link

Connect it up

Draw it

Draw one prefab asset on the left and three instances on the right, with an arrow from the asset to each. Cut one arrow with a cross and label what that instance now ignores - and what it still follows.

60. Before you close this

Exit ticket

Predict first

Which is still shakiest?

  • Prefab asset vs scene instance
  • Which window I am editing in
  • That an override is permanent
  • Instantiate at runtime

Correct: Whichever you picked - open the lab and run the six menu steps for that one.

Why: This was the joint-lowest topic in the diagnostic at 1 out of 3, so a shaky spot here is expected rather than embarrassing. Name it, then run the lab's step sequence: it was built to make each of those four visible in under a minute.

61. What you can now do

Recap

You can tell, before clicking, whether an edit will reach one object or fifty.

Lab: unity-labs/Assets/NaruhodoLabs/Lesson02_Prefabs/SETUP.md. Run all six menu steps in order, then go to lesson 3.

Sources

  1. Unity Manual - Prefabs
  2. Unity Manual - Editing a prefab via its instances
  3. Unity Manual - Editing a prefab in Prefab Mode
  4. Unity Scripting API - Object.Instantiate
  5. Naruhodo Unity Labs - Lesson 02 setup notes — unity-labs/Assets/NaruhodoLabs/Lesson02_Prefabs/SETUP.md

Want this taught 1-on-1? Alexander tutors Unity Game Engine — $55/session, free consultation.

Book on Wyzant · Text (657) 465-8108