Prefab Editing Guide¶
Modify prefab assets directly without unpacking to scene.
Overview¶
The edit action lets you modify prefab component properties, add/remove components, all without instantiating the prefab in the scene. Available since v0.56.0.
When to Use Prefab Edit vs set_property¶
| Task | Use | Why |
|---|---|---|
| Modify prefab template | prefab(action=edit) | Changes all future instances |
| Modify scene instance | set_property | Only affects that object |
| Add component to prefab | prefab(action=edit, add_component=...) | All instances inherit |
| Add to scene object | manage_component | Only that object |
Syntax¶
# Edit property
await prefab("edit",
asset_path="Assets/Prefabs/Player.prefab",
component="Health",
prop="MaxHP",
value="200")
# Add component
await prefab("edit",
asset_path="Assets/Prefabs/Enemy.prefab",
add_component="Rigidbody")
# Remove component
await prefab("edit",
asset_path="Assets/Prefabs/Projectile.prefab",
remove_component="AudioSource")
Examples¶
Change max health for all Player instances:
await prefab("edit",
asset_path="Assets/Prefabs/Player.prefab",
component="Health",
prop="MaxHP",
value="150")
# → All spawned Player prefabs now have MaxHP=150
Add rigid body to bomb prefab:
Remove audio from silent enemy variant:
await prefab("edit",
asset_path="Assets/Prefabs/SilentEnemy.prefab",
remove_component="AudioSource")
Workflow: Design → Save → Edit¶
-
Design in scene first:
-
Save as prefab:
-
Edit prefab directly (no unpacking):
-
Spawn instances:
Supported Operations¶
✅ Can edit: - Public properties (int, float, string, bool, Vector3, Quaternion) - ObjectReferences (assign by path or GUID) - Color, Bounds, Rect - Collections (arrays, lists)
❌ Cannot edit: - Private fields (reflection not allowed) - Non-serializable types - Nested ScriptableObjects (use scriptable_object tool instead)
Verification¶
After editing, verify the change persisted:
await prefab("edit",
asset_path="Assets/Prefabs/Player.prefab",
component="Health",
prop="MaxHP",
value="200")
# Verify by spawning instance
await create_object(name="TestPlayer", prefab_path="Assets/Prefabs/Player.prefab")
health = await get_component("TestPlayer", "Health")
# → Should show MaxHP: 200
See also: Asset Management for asset operations, Object Tools for scene instances.