S&box Wiki

Prefabs

What are prefabs?

A prefab is a collection of models, entities, or both organized into a single object that is saved out into a separate VMAP file. It's similar to a group that can be moved around as one but different as it is treated as a single object in the map.

If the prefab is altered it should be saved to its current prefab VMAP file. All other maps using this prefab will be updated (they will require recompiling as the change is not populated until the map with the updated prefab is loaded)

Creating Prefabs

  1. Select a number of objects and/or meshes
selectionbox.png
  1. Right click to bring up the context menu and Selected Objects -> New Prefab From Selection (Center on Origin)
createprefaborigin.png
  1. This will create the prefab and ask to save a new VMAP

  2. Choose an appropriate name and save the VMAP

savingvmap.png
  1. The prefab is now live in the world
liveprefab.png

Editing Prefabs

You can edit prefabs inside the map you're working on. Just double-click on the prefab you want to edit. Any changes you make to that prefab will propagate in every instance of that prefab that was placed on your map.

Collapsing Prefabs

To collapse a prefab, select it, right click to bring up the context menu Selected Prefabs -> Collapse.

When a prefab is collapsed all the objects are left in the world and can be edited on their own as if they were placed individually.

Links

If you want to know about Instances, we have it covered.