Skip to content

Latest commit

 

History

History
54 lines (33 loc) · 2.88 KB

index.md

File metadata and controls

54 lines (33 loc) · 2.88 KB

Prefabs

Prefabs

Prefab is an asset that contains serialized actors hierarchy including scripts and data. The prefab acts like a template or an archetype which you can spawn in the scene. Any edits made to a prefab asset are immediately reflected in all instances produced from it but you can also override components and settings for each instance individually.

Flax supports creating Nested Prefabs which means you can use objects from prefab inside the other prefabs. This helps with creating advanced gameplay content.

Both prefabs creating and changed applying is supported only in Editor. However, prefabs spawning is dedicated to being used at runtime right in your game. Use this documentation section to learn more about creating and using prefabs.

Topics

Learn how to create a new prefab asset.

Learn how to open and edit prefab assets.

Learn how to add prefab objects to you game.

Prefabs in Editor

Spawned prefabs are called prefab instances and contain a link to the prefab asset and the reference object from the prefab. Editor highlights the prefab instances in the Scene Window as shown in the picture below.

Prefab Instance in Editor

After selecting prefab instance Properties Window shows two additional buttons on top of the panel: Select Prefab and View Changes.

Prefab Instance Diff Popup

Select Prefab button shows the linked prefab asset location in Content Window and select it.

View Changes button shows the popup with modified actor and scripts properties compared to the prefab. It is used to see all the changes applied to the prefab instance and allows to revert them or apply to the prefab. The picture below shows a sample prefab changes popup contents. You can right click on modified tree nodes to revert the per-property change while keeping other modification unchanged.

Prefab Instance Diff Popup

You can also see per-property modifications applied to the prefab instance. Editor shows them by highlighting the label of the changed property as shown in the picture below. You ca right click on it and revert the changes applied to this property (with undo support).

Prefab Instance Diff Popup