Prefabs

From Wolfire Games Wiki
(Difference between revisions)
Jump to: navigation, search
m (removed overview heading)
m
 
Line 1: Line 1:
 
[[Category:Modding]]
 
[[Category:Modding]]
 
[[Category:Overgrowth]]
 
[[Category:Overgrowth]]
 
 
A prefab is a file containing one or more objects. The file itself can be used as an object in a level, meaning if the prefab file is updated, all objects pointing to that file will also be updated with the changes.
 
A prefab is a file containing one or more objects. The file itself can be used as an object in a level, meaning if the prefab file is updated, all objects pointing to that file will also be updated with the changes.
  

Latest revision as of 14:47, 6 February 2018

A prefab is a file containing one or more objects. The file itself can be used as an object in a level, meaning if the prefab file is updated, all objects pointing to that file will also be updated with the changes.

Prefabs are useful time savers. For instance you can make a few tree prefabs and use them in your level, so if you ever need to later update your trees, you just need to change a few prefabs instead of having to replace every tree. Maybe you want to create a standardized type of character, then you can create a prefab containing a character with sine armor attached, maybe a weapon, colors, settings and so on, that you can load into any level. If you want to change the colors or armor of all characters of that type you can just edit the prefab.

Creating a Prefab

Follow these steps to create a prefab:

  1. Create what you want to make a prefab of in a level
  2. Select all the objects that should be in the prefab
  3. In the top menu bar, press "Selected → Prefab Save As..." and save it wherever you want it

Now you have created a prefab, which you can see because the objects will now have a turqoise box around them. You can now copy/paste or duplicate this prefab, or load it via the top menu bar "Load → Load item...".

Updating a Prefab

To update an existing prefab so that every instance of it is also changed, all you have to do is replace the prefab file. Here are some more detailed instructions:

  1. Load the prefab into a level and place it somewhere where you can easily select 'only' the prefab later on with box seelct for instance (B+left click and drag)
  2. Select the prefab and press cmd+shift+G to ungroup the prefab into separate objects
  3. Make the changes you want to the objects, add objects etc.
  4. Select all the objects you want to have in the prefab (this is why you made it easy to box select all objects before)
  5. In the top menu bar, press "Selected → Prefab Save As..." and save over the prefab you loaded.

Once you save over the prefab it should instantly update all instances of this prefab in the loaded level with the changes.

Personal tools