Reusable Components (Prefabs)
How to build up your own reuse library
Last updated
How to build up your own reuse library
Last updated
This page is currently work in progress
Prefabs are powerful assets that allow developers to create, store, and reuse preconfigured game objects and their components.
The PrefabGenerator
is a utility designed to simplify the creation of prefabs. It operates in the Unity Editor and automates the process of generating prefabs, including handling sub-assets such as dynamically created meshes within child objects.
Before creating a prefab, optimize meshes using tools like Mesh Optimizer to reduce polygon count and Mesh Combine to merge multiple meshes into a single mesh.
In addition to optimizing meshes, ensure materials are instances to improve performance. Use the Material Window in realvirtual for quick material replacement. Another option is to use the CAD import feature to create an instantiated material set during data import (option: "Set and Create Materials")
Select the GameObject in the Scene Hierarchy that you want to convert into a prefab.
Right-Click in the hierarchy area and select realvirtual/Create Prefab
A prefab will be created in the Assets/
folder with the same name as the selected GameObject.
In this example, we start with a CNC machine where components like "Drives" are already defined, along with some group definitions. To prepare this GameObject as a prefab, follow these steps: