RoadRunner can export scenes to Unity® format. The Unity export option exports a Filmbox (.fbx) file containing the 3D objects in a scene along with an additional XML file to hold extra data for materials and traffic signals in the scene.
On the Unity side, a set of scripts are included in the RoadRunnerUnityTool asset package to help import the FBX® file using the information stored in the XML file. The script handles the following details:
Setting up materials
Material data is read in from the XML file and mapped into the included custom shaders.
Adding colliders to roads and terrain
Colliders are added to all imported meshes.
Setting up the components of traffic signals
Signal data is read in from the XML file to create a new game object in the prefab, with the light bulb references to game objects set up during import.
The traffic signals will cycle through their phases during play mode.
The UUIDs prefixed in the game object for prop instances are needed only at import time to set up references to game objects in the traffic signal script so that they can be renamed freely.
Unity software requirements: Unity Version 2017.3+
Follow the instructions in this section to install the Import Tool into your Unity project.
See the page Downloading Plugins for instructions for downloading the latest version of the plugin.
Extract the RoadRunner Plugins zip file and locate the "RoadRunnerUnityTool.unitypackage" file in the "Unity" folder.
Open your project in Unity.
Open the RoadRunnerUnityTool asset package file to import it. Alternatively, drag the package file into the Unity Project window, or select
Assets > Import Package > Custom Package and then select the package file.
Click Import in the Import Unity Package dialog box.
The package includes some extra files to add a drivable vehicle to your scene. If you do not need these extra files, then you can deselect them when you import the package.
The essential scripts inside the "RoadRunner" folder are needed to set up the materials and traffic signals in the scene.
Models: Mesh, materials, and textures for the drivable car prefab.
Prefabs: The prefab for the car with scripts set up.
ImportWindow.cs: Editor window to display messages for the RoadRunner importer.
RoadRunnerImporter.cs: Editor script for importing the FBX file with the data from the XML file.
Metadata.cs: Contains classes to hold the imported metadata XML file.
TrafficJunction.cs: Component for controlling signals from data in the XML file at import time.
Various shaders to match RoadRunner material settings.
Scripts: For the Sedan prefab.
Standard Assets: For the Sedan prefab.
Follow these steps to export a scene from RoadRunner to Unity:
Open your scene in RoadRunner.
Export the scene to Unity format using File > Export > Unity (.fbx + .xml) from the Main Menu.
In the Export Unity dialog box, set your desired options, and then click Export.
Browse to open the file dialog box to set the exported file's name and path. The textures and the XML file are exported to the same folder. (Tip: Create a new folder when choosing a file location, so you can import the entire folder into Unity.)
The mesh can be split by segmentation type. Meshes have "<segmentation type>Node" appended to their names.
If the Export To Tiles option is selected, meshes are split per tile. Props are grouped by the tile they are in.
By default, only one file is exported. Tiles are stored in separate nodes.
If Export Individual Tiles is enabled, each tile will be stored in its own FBX file.
When exporting with Embed Textures selected, you need to manually extract the textures inside Unity.
To import a scene into Unity that you previously exported from RoadRunner, drag all the exported files (or the entire folder) into the Unity project window. Alternatively, use Assets > Import New Asset in Unity and select all the exported files.
The output window that opens contains log messages from the import plugin.
You can place and drive a car model around an imported scene by following these steps:
Drag the Sedan prefab from the Prefabs folder into the scene. (Note: In some versions of Unity, you might need to manually tag the Main Camera as "MainCamera" for some scripts to work.)
If traffic signals were set up in RoadRunner, then they are imported into Unity as junction controllers. These controllers are automatically created during import and attached to the prefab.
Prop instances for traffic signals are prefixed by their UUID so that the traffic signal controller has a way to identify which signals it controls. The TrafficJunction script handles the logic for switching between signal states.
The FBX file is identical to the one exported from the Filmbox export option. The only difference is the extra rrdata.xml metadata file.
The RoadRunnerUnityTool unitypackage also includes the RoadRunner Sedan 3D model. This section covers how to set it up with Unity Standard Assets.
The following section was tested on Unity 2019.1. Older versions might require different steps to modify prefabs.
Download the "Standard Assets (for Unity 2017.3)" package from the Unity Asset Store.
Select the following folders to import:
Import the package by clicking Import.
Select the Sedan prefab (located in "Assets/Prefabs") and click Open Prefab in the Inspector window.
For each Wheel Hub Game Object under "Sedan/WheelsHubs" (for example, "WheelHubFrontRight"), complete these steps:
Add the "Wheel Effects" component.
Set the "Skid Trail Prefab" to the "SkidTrail" Prefab (located in "Assets/Standard Assets/Vehicles/Car/Prefabs").
Set the Audio Source's "AudioClip" to the "Skid" sound effect if it is missing.
Select the top level "Sedan" game object in the hierarchy window.
Add the "Car Controller" component with the following settings.
To avoid errors, verify that the order of the wheels is correct.
Add the "Car Audio" component with the following settings.
Add the "Car User Control" component.
Select the "light_brakes" game object.
Add the "Brake Light" component and set the "Car" property to the top level "Sedan" game object.
Select the "ParticleBurnoutSmoke" game object.
Enable the game object.
Set the Particle System component's Renderer Material property to "ParticleSmokeWhite".
Exit Prefab edit mode.
Delete any existing cameras in the scene.
Add the Sedan prefab to the scene.
Add the "MultipurposeCameraRig" prefab (located in "Standard Assets/Cameras/Prefabs") to the scene with the following settings.
Add in an imported RoadRunner scene and click play to drive around in it.