# Create Prefab (Pro)

### Introduction

While Unity provides a standard prefab workflow, **realvirtual goes a step further** with its own **Create Prefab** function. This tool is designed specifically for **industrial simulation workflows**, allowing you to generate **self-contained, reusable assets** that include not only meshes and hierarchy but also the logic components that define behavior—such as drives, signals, sensors, and automation interfaces.

> 💡 **Hint:** You should typically use this function **after preparing and optimizing your GameObject**—for example, after using Combine Meshes—to turn it into a **lightweight, modular component**.

### Overview

The `Create Prefab` function in realvirtual creates a prefab asset that includes:

* The complete **GameObject hierarchy**
* All associated **meshes** (combined or separate)
* All attached **realvirtual components**, such as:
  * Drives
  * Signals
  * Sensors
  * Kinematic groups
  * Custom logic or automation interfaces

This ensures the prefab is fully portable and ready for use in any simulation context built with realvirtual.

### Scene Mesh Handling

Unlike Unity’s standard workflow, realvirtual's `Create Prefab` works seamlessly even when:

* Meshes are still **embedded in the scene**, for example after a **CADLink import**
* Meshes have been **combined** using the Combine Meshes utility

It acts similarly to an **FBX export**, but instead of creating an external file, it generates a single prefab **containing all geometry, hierarchy, and logic in one asset**—ready for reuse and versioning in your simulation workflows.

### When to Use

* After optimizing an imported CAD structure
* When creating **reusable standard components**
* When preparing modular assets for **parts libraries or versioned assets**
* Before exporting or distributing simulation-ready components

### How to Use

1. **Select the root GameObject**\
   Choose the GameObject that includes all child objects and components you want to include in the prefab.
2. **Run Create Prefab**\
   Right-click on the selection in the Hierarchy and choose:\
   \&#xNAN;**`realvirtual/Create Prefab`**

<figure><img src="/files/JtmW3Q1qJmAbuE6oh44A" alt=""><figcaption><p>Create prefab in Gameobject context menu</p></figcaption></figure>

3. **Result**\
   The prefab will be automatically created under the **`Assets/`** folder of your project.

<figure><img src="/files/qq4P4oosgSHLEQqxs1Mk" alt=""><figcaption><p>Exported prefab</p></figcaption></figure>

3. **Organize**\
   If needed, manually **move the prefab** to your desired location within the Unity project (e.g., `Assets/Prefabs/[ExportedPrefab]`).

> 📦 The resulting `.prefab` file contains the full structure, geometry, and behavior. It’s fully reusable across scenes and projects and supports realvirtual's simulation features out of the box.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doc.realvirtual.io/components-and-scripts/performance-tools/create-prefab-pro.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
