Prefabs — save, instance, and unpack
site/media/lessons/learn-prefab.lesson.ts (4 steps) A prefab is an entity (with its children, components, and physics) saved to a reusable
.prefab.json. Drop it into any scene to get an instance linked back to that file. This scene
ships two pillar instances of prefabs/pillar.prefab.json.
-
Spot an instance. Selecting
PillarLeftshows a blue Prefab banner in the inspector (Prefab · pillar) with Open and Unpack — that’s how you know an entity is a linked instance, not a one-off.
An instance carries a Prefab banner linking it to its .prefab.json. -
The instance context menu. Right-clicking an instance offers Unpack Prefab (break the link) and Open Prefab (edit the source asset in prefab mode).
Unpack Prefab / Open Prefab on an instance. -
Author a new prefab. Right-clicking a plain entity offers Save as Prefab…, which opens the save dialog — pick a folder and name, and it writes
prefabs/StandardBox.prefab.json.
Save any entity (and its subtree) as a reusable .prefab.json. -
Unpack an instance. Unpack replaces the instance with plain, editable copies of its contents — here
PillarLeftbecomes a normal entity (white), whilePillarRightstays a linked instance (blue).
Unpacked: PillarLeft is now plain; PillarRight is still an instance.
Recap
New functionality
- Identified a prefab instance by its banner
- Opened the Save-as-Prefab dialog on a plain entity
- Unpacked an instance into plain entities
New concepts & skills
- a prefab is an entity subtree saved to a reusable .prefab.json
- instances link back to the source (blue in the tree) and can override / nest
- Unpack bakes an instance into plain entities and drops the link
Next lesson → Edit ops
On Your Own!
Extend what you built:
- Save a decorated entity as a prefab, then drag two instances into the scene
- Open a prefab (Open Prefab) and edit the source — every instance updates
- Unpack one instance and leave another linked; compare how edits propagate