S&box Wiki

Revision Difference

Prefabs#548670

<cat>Hammer.Advanced</cat>⤶ <title>Prefabs</title>⤶ ⤶ # 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⤶ <upload src="b0065/8dafa3d3990f678.png" size="399799" name="selectionbox.png" />⤶ 2. Right click to bring up the context menu and `Selected Objects` -> `New Prefab From Selection (Center on Origin)`⤶ <upload src="b0065/8dafa3dc5f06809.png" size="446874" name="createprefaborigin.png" />⤶ 3. This will create the prefab and ask to save a new VMAP⤶ ⤶ 4. Choose an appropriate name and save the VMAP⤶ <upload src="b0065/8dafa3dda9644a4.png" size="4755" name="savingvmap.png" />⤶ ⤶ 5. The prefab is now live in the world⤶ <upload src="b0065/8dafa3e356e7ab2.png" size="447977" name="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 <page>Instances</page>, we have it covered.