Often, you want to create a large number of identical objects: a set of cars, a battalion of soldiers, or trees in a forest. Prototype and prefab assets provide a convenient way to make multiple objects that are identical. The LevelEditor treats a prototype or prefab asset as any other game resource or asset, and you can place as many of the prototype or prefab assets in the world as you need. The following table describes the similarities and differences between prototype assets and prefab assets.
Prototype Assets |
Prefab Assets |
When you drag and drop a prototype asset to the Design View, LevelEditor creates a copy of the base prototype object as the newly created object. If you edit the properties of a base prototype asset, those changes do not affect any instances (copies) of that prototype in the game level. |
When you drag and drop a prefab asset to the Design View, LevelEditor creates a reference from the base prefab object to the newly created object. If you edit the properties of a base prefab asset, those changes also affect all instances of that prefab in the game level. If you edit the properties of an instance of a prefab asset, those changes remain local to that instance (they override those of the base prefab, but do not affect the base prefab itself). |
To create a prototype or prefab asset, you must first create one or more game objects, set properties for each object, and associate resources with them. You then create a prototype or prefab asset from the game objects, and use the prototype or prefab asset as a template.
To create a prototype asset:
To create a prefab asset:
To use a prototype or prefab asset to create additional instances of a game object or set of game objects:
Game objects created from prototype assets appear in the Project Lister within a GameObjectGroup object, with each copy of the prototype as a child of the GameObjectGroup, whereas game objects created from prefab assets appear in the Project Lister as child objects of the prefab instance. You can work with each object individually by selecting the object; to work with the objects as a group, select the prototype's GameObjectGroup or the prefab instance in the Project Lister.