Razorbill
Operations

Prefab Operations

CreatePrefab

Save a scene entity (and its descendants) as a reusable prefab file in Content/Prefabs/.

ParameterTypeRequiredDescription
prefab_namestringYesName for the prefab (without .prefab extension)
source_entity_guidstringYesGUID of the entity to capture
prefab_guidstringNoSpecific 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.

ParameterTypeRequiredDescription
prefab_namestringYesPrefab name (without .prefab extension)
parentstringNoParent entity GUID for the instance root
root_instance_guidstringNoSpecific 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" }
  }
]

On this page