realvirtual.io
  • Building Digital Twins with Unity and realvirtual.io
  • Basics
    • Installation
    • Demo Model
      • Old Demo Model
    • Editor User Interface
      • Hierarchy Window
      • 3D Views
      • Quick Edit
      • Move Pivot Points (Pro)
      • Selection Window (Pro)
      • Material Window (Pro)
      • Measurement (Pro)
      • Kinematic Tool (Pro)
      • Model Checker
    • Runtime UI
      • Group Manager
      • Debug Console
      • Responsiveness
      • Runtime Persistence
    • Importing and exporting
    • Folder structure
    • Tutorial
    • Physics
    • CAD import (Pro)
      • CADLink (Pro)
      • CAD Checker (Pro)
      • CAD Updater (Pro)
    • Reusable Components (Prefabs)
    • Cadenas parts4cad
    • Publishing the Digital Twin
    • Revision management
  • News
  • Login & Download Updates (Pro)
  • Components & Scripts
    • Realvirtual
      • Environment Controller
    • MU, Source and Sink
      • Source
      • Sink
    • Motion and Kinematic
      • Drive
      • Kinematic
      • Group
      • Joint
      • CAM
      • TransportSurface
      • Guided Transport
      • Drive behavior
      • Chain
      • Chain element
      • Motion for developers
    • Sensors
      • Sensor
      • Measure
      • MeasureRaycast
    • Picking and Placing MUs
      • Grip
      • Gripper
      • Fixer
      • Pattern
    • Changing MUs
      • MaterialChanger
      • PartChanger
      • Cutter
    • Scene Interaction
      • 3D Buttons
      • Screen Overlay Buttons
      • Scene Selectables
      • Lamp
      • Interact3D
      • UI components
      • HMI components (Pro)
        • Start your own HMI
        • HMI Tab
        • HMI DropDown
        • HMI Puschbutton
        • HMI Switch
        • HMI Value
        • HMI Text
        • HMI Slider
        • HMI Message
        • HMI Marker
      • ModelZoo (Pro)
    • Interfaces
      • Interface Tools
        • Signal Manager
        • Signal Importer Exporter
        • Signal Catcher
        • OnValueChangedReconnect
      • Signal Importer / Exporter
      • ABB RobotStudio (Pro)
      • Denso Robotics (Pro)
      • EthernetIP (Pro)
      • Fanuc (Pro)
      • FMI
      • Igus Rebel
      • MQTT (Pro)
      • Modbus (Pro)
      • OPCUA (Pro)
      • PLCSIM Advanced (Pro)
      • RoboDK (Pro)
      • RFSuite (Pro)
      • SEW SimInterface (Pro)
      • Siemens Simit Interface (Pro)
      • Simit Shared Memory (Pro)
      • Simulink (Pro)
      • S7 TCP
      • TwinCAT (Pro)
      • TwinCAT HMI (Pro)
      • UDP (Pro)
      • Universal Robots (Pro)
      • Wandelbots Nova (Pro)
      • Websocket (Pro)
      • Windmod Y200 (Pro)
      • Custom Interfaces
    • Performance Tools
      • Combine Meshes (Pro)
      • Create Prefab (Pro)
      • Hierarchy Cleanup (Pro)
      • Mesh Optimizer (Pro)
      • Performance Optimizer (Pro)
    • Defining Logic
      • Unity Scripting
      • Behavior Graph
      • Logicsteps
      • Unity Visual Scripting
      • Recorder
    • Robot Inverse Kinematics (Pro)
    • Volume Tracking (Pro)
  • Multiplayer (Pro)
  • Extensions
    • ModelZoo
      • Beckhoff TwinCAT
      • Siemens S7
      • Denso Cobotta 1300
      • Wandelbots Nova Fanuc CRX
      • Universal Robots UR10
      • Fanuc Roboguide
    • realvirtual.io AIBuilder
      • realvirtual.io AI Builder Overview
      • Generate AI Training Data
      • AI Training
      • Testing AI in a Digital Twin
      • Deploying the AI
    • realvirtual.io Simulation
      • Conveyor Library
      • Path System
        • Path finding
        • Line
        • Curve
        • Workstation
        • Catcher
        • Pathmover
    • realvirtual.io Industrial Metaverse
      • Setup Guide
      • VR Modules
      • AR Modules
      • Multiuser
    • AGX Physics
    • VR Builder
    • CMC ViewR
  • Advanced Topics
    • Render Pipelines
    • Mixed Reality with Meta Quest3
    • Upgrade Guide
      • Upgrade to 2022
    • Open Digital Twin Interface
    • Usefull Addons
    • Improving Performance
    • Supported Platforms
    • Compiler Defines
    • For Developers
      • Important Classes and Interfaces
      • Assembly Definitions
      • Starting your development
      • Class documentation
      • realvirtual Init Sequence
      • realvirtualBehavior Lifetime Methods
      • Testing
    • Newtonsoft JSON
    • Troubleshooting
  • Release Notes
  • AI Digital Twin Assistant (GPT4)
  • License Conditions
Powered by GitBook
On this page
  • Overview
  • Creating Prefabs in realvirtual (Pro)
  • Usage
  • Example
Edit on GitHub
  1. Basics

Reusable Components (Prefabs)

How to build up your own reuse library. Only available with the professional version.

PreviousCAD Updater (Pro)NextCadenas parts4cad

Last updated 9 days ago

Overview

Prefabs are powerful assets that allow developers to create, store, and reuse preconfigured game objects and their components.

When creating optimal prefabs for your project, keep the following best practices in mind:

  1. Simplify GameObject Structure Ensure the hierarchy is as simple as possible. Avoid unnecessary nesting or components to improve performance and maintainability. The realvirtual tool "" supports this.

  2. Use Instantiated Materials All materials should be instantiated. This helps reduce memory usage and allows efficient batching during rendering. You can use the option "Set and Create Materials" in the component and create instantiated materials when importing your data.

  3. Use Instantiated Meshes Ensure that meshes are unique instances to avoid conflicts and improve compatibility when creating prefabs.

  4. Combine Meshes If components consists of several meshes use the to merge multiple meshes into a single mesh.

  5. Share Materials Where Possible Use shared materials across multiple objects to minimize the number of draw calls. The fewer unique materials, the better the performance.

By adhering to these principles, you can create prefabs that are efficient, scalable, and ready for integration into complex projects.

Creating Prefabs in realvirtual (Pro)

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. It also considers Drives, Kinematics, and Group definitions, preserving their structure when creating the prefab. The PrefabGenerator also includes instantiated meshes in the scene (e.g., from previous combining), resulting in lighter scenes.

Combine Meshs and Create Prefab are only included in realvirtual.io Professional version

Please also check detailled documentation here:

Usage

  • 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.

Example

For the 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:

  • Clean up the hierarchy: realvirtual/Clean up Hierarchy

  • using realvirtual/Combine Meshes for every main Game Object

After these steps the structure look like this:

Now your Game Object is prepared and ready to create a prefab:

Mesh Combine
Combine Meshes
Create Prefab
Game Object structure after import: starting point
Clean Up Hierarchy
CAD link