Skip to main content
A prefab is a saved GameObject that you can reuse across multiple scenes or spawn dynamically at runtime. When you update a prefab asset, every instance of it in every scene updates automatically.

Creating a prefab

1

Set up your GameObject

In the scene, create and configure the GameObject you want to turn into a prefab — add components, child objects, and set properties as needed.
2

Convert to prefab

Right-click the GameObject in the Scene panel and select Convert to Prefab. s&box saves the GameObject as a PrefabFile asset on disk.

Prefabs in the scene

Prefab instances in the scene appear in a distinct colour to make them easy to identify at a glance.
When a GameObject is in its Prefab Instantiation state, you cannot view or select objects inside its hierarchy. To edit the contents directly in the scene, right-click the prefab and choose Unlink from Prefab to convert it to regular GameObjects.

Instantiating prefabs at runtime

Reference a prefab in your component using a GameObject property and drag a PrefabFile asset into the slot in the Inspector:
public sealed class MyGun : Component
{
    [Property]
    GameObject BulletPrefab { get; set; }

    protected override void OnUpdate()
    {
        // Throw an error if BulletPrefab wasn't assigned in the Inspector
        Assert.NotNull( BulletPrefab );

        if ( Input.Pressed( "Attack1" ) )
        {
            // Create a new instance of the bullet prefab at the gun's world position
            GameObject bullet = BulletPrefab.Clone( WorldPosition );

            // bullet is now live in the scene — get components and configure it
        }
    }
}
A cloned prefab remains linked to its source asset. Call BreakFromPrefab() on it if you want to detach the instance and treat it as a standalone set of GameObjects:
bullet.BreakFromPrefab();

Updating a prefab

Edit the PrefabFile asset directly — open it from the asset browser or double-click a prefab instance in the scene. When you save your changes, all instances of the prefab in all open scenes update to reflect the new configuration.
Keep shared game objects — like enemies, pickups, or effects — as prefabs so you can tweak their values in one place and have changes propagate everywhere automatically.