Eonevolve Learning
Unity and DevelopmentUnity and codeBeginner~5 min

Prefabs: One Source, Many Instances

Snapshot

~70 sec

A prefab is a saved, reusable GameObject template. Every copy placed in a scene is an instance that can carry small overrides without touching the shared source. Confusing an instance for the source is how one edit accidentally changes every copy.

You will learn

  • Separate a prefab asset from the instances built from it.
  • Explain what a prefab override is and when it survives a source update.
  • Predict what changes across all instances when you edit the prefab source directly.

Target outcome

You can decide whether an edit belongs on the prefab source or on one instance's override.

Visual walkthrough

Visual walkthrough

~5 min

  1. Three roles in the prefab system

    • Prefab source

      The saved asset on disk - the single template every instance is built from.

    • Instance

      A copy of the prefab placed in a scene. Many instances can share one source.

    • Override

      A per-instance change (a moved position, a swapped sprite) that does not touch the shared source.

  2. One source, three instances, one override

    Edits on the source ripple to every instance. An override lives only on the one instance that declared it.

    1. Prefab source: Coin

      Sprite, collider, and CoinValue script live here.

    2. Instance A

      Default - matches the source exactly.

    3. Instance B

      Override: position moved to a ledge.

    4. Instance C

      Override: sprite swapped to a gold variant.

    Edits on the source ripple to every instance. An override lives only on the one instance that declared it.

    Reading order

    1. Prefab source: Coin

      Sprite, collider, and CoinValue script live here.

    2. Instance A

      Default - matches the source exactly.

    3. Instance B

      Override: position moved to a ledge.

    4. Instance C

      Override: sprite swapped to a gold variant.

    Connection explanations

    1. Prefab source: Coin → Instance A (instantiates)

      Instance A has no overrides, so any future source edit reaches it unchanged.

    2. Prefab source: Coin → Instance B (instantiates)

      Instance B keeps the source's script and sprite, but its position override survives a source update.

    3. Prefab source: Coin → Instance C (instantiates)

      Instance C's sprite override is per-instance; editing the source's default sprite still will not touch this one.

  3. Decide where the fix belongs

    Every Coin instance in your level is floating slightly above the ground because the source's collider offset is wrong. Should you fix each instance, or the prefab source?

    Expected reasoning

    Fix the prefab source. The collider offset is a shared design flaw, not a per-instance choice, so correcting the source updates every instance at once - including ones you have not placed yet - without creating dozens of scattered overrides.

Go deeper