Prefab Operations
CreatePrefab
Save a scene entity (and its descendants) as a reusable prefab file in Content/Prefabs/.
| Parameter | Type | Required | Description |
|---|---|---|---|
prefab_name | string | Yes | Name for the prefab (without .prefab extension) |
source_entity_guid | string | Yes | GUID of the entity to capture |
prefab_guid | string | No | Specific GUID for the prefab (for redo) |
{
"op": "CreatePrefab",
"params": {
"prefab_name": "EnemySoldier",
"source_entity_guid": "a1b2c3d4-..."
}
}
This captures the entity's full component data and child hierarchy into a .prefab file that can be instantiated multiple times.
InstantiatePrefab
Create scene entities from a saved prefab.
| Parameter | Type | Required | Description |
|---|---|---|---|
prefab_name | string | Yes | Prefab name (without .prefab extension) |
parent | string | No | Parent entity GUID for the instance root |
root_instance_guid | string | No | Specific GUID for the root entity (for redo) |
{
"op": "InstantiatePrefab",
"params": {
"prefab_name": "EnemySoldier",
"parent": "e5f6a7b8-..."
}
}
Each instantiation creates new entities with fresh scene GUIDs while maintaining a stable prefab entity GUID linking back to the source. This dual-GUID architecture enables override tracking.
Overrides
When you modify a property on a prefab instance, the change is stored as an override patch — not a full copy. This means:
- Non-overridden properties update automatically when the source prefab changes
- Overridden properties are preserved and take priority over the prefab source
- Overrides are stored at the instance root for easy lookup
- The editor shows overridden properties with a visual indicator
Propagation
When a source prefab is modified, all instances in every scene update their non-overridden properties. This makes prefabs ideal for shared objects like enemies, pickups, or furniture that should stay consistent.
Example: Create and Reuse
[
{
"op": "CreatePrimitive",
"params": { "primitive_type": "Cube", "entity_name": "Crate", "position": [0, 0.5, 0] }
},
{
"op": "AddComponent",
"params": { "entity_name": "Crate", "component_type": "Rigidbody", "data": { "mass": 5.0 } }
},
{
"op": "AddComponent",
"params": { "entity_name": "Crate", "component_type": "Collider", "data": { "shape": "box" } }
},
{
"op": "CreatePrefab",
"params": { "prefab_name": "PhysicsCrate", "source_entity_guid": "<crate-guid>" }
},
{
"op": "InstantiatePrefab",
"params": { "prefab_name": "PhysicsCrate" }
},
{
"op": "InstantiatePrefab",
"params": { "prefab_name": "PhysicsCrate" }
}
]