3D Car HMI Tutorial with ProtoPie Connect Unity Plugin
Follow this tutorial to create a 3D car HMI experience using the ProtoPie Connect Unity plugin.
![Luke Han](https://cdn.sanity.io/images/qyzm5ged/blog/13be596a45a482467e5801e398ebff5e154372b1-72x72.jpg/Luke-Product-Manager.jpeg)
![3d car hmi](https://cdn.sanity.io/images/qyzm5ged/blog/061ca1dbdc530e8565771739366b0da3df92a5d8-2138x1200.jpg/Thumbnail-v1-(2).jpg)
Overview
- What is the Unity plugin?
- How to use Unity projects in ProtoPie Connect
- Step 1. Set up the Unity project
- Step 2. Configure the ProtoPie prototype
- Step 3. Configure message mapping
- Step 4. Build the Unity project
- Step 5. Test the interaction in ProtoPie Connect
- Workflow for integrating Unity with ProtoPie
- Tips for an effective Unity-ProtoPie integration
This step-by-step tutorial will guide you through creating a 3D car HMI experience using the ProtoPie Connect Unity plugin. Follow along to learn about the Unity plugin, how it works, and how to import and test Unity projects with ProtoPie Connect.
To get started, watch the video beginning at 10:12.
What is the Unity plugin?
First, let’s cover some basics: the Unity plugin and how to use it in ProtoPie Connect.
The ProtoPie Connect Unity plugin is a no-code solution that allows ProtoPie to interact with Unity layers. This plugin enables deep integration of ProtoPie with Unity, providing endless possibilities for creating complex and interactive prototypes. It is particularly useful for industries such as automotive, game, VR, and MedTech, but it can also be applied to many other fields.
![the protopie connect unity plugin](https://cdn.sanity.io/images/qyzm5ged/blog/ec3a1c64369252e9316a1e98d5cf8e48fc3c85a7-2000x1128.png/unitypl.png)
How to use Unity projects in ProtoPie Connect
Before we start the tutorial, let's also understand what custom layers are and how we can use them to bring Unity projects to ProtoPie Connect.
ProtoPie Connect's Stage View enables you to integrate ProtoPie prototypes with various custom layers, including web content, embedded elements, live cameras, and Unity projects. This integration enhances the user testing experience and makes your designs more dynamic.
![Bringing Unity projects into ProtoPie through the Unity layer.](https://cdn.sanity.io/images/qyzm5ged/blog/209fee866247bcbf52ddb6b2d18564b04cc79020-800x520.gif/gifprotopie.gif)
Now, let’s dive into our tutorial.
Step 1. Set up the Unity project
1.1 Download the automotive HMI template
We are using a modified automotive HMI template from the Unity Asset Store for this tutorial. This version includes only the specific 3D car elements needed for the demo. You can download the original file from this link.
![Download the automotive HMI template and open it in Unity.](https://cdn.sanity.io/images/qyzm5ged/blog/35629824841189ec418557a85c6e219ad9a3cbe8-2482x1552.png/CleanShot-2024-07-01-at-21.50.54@2x.png)
1.2 Prepare the Unity scene
- Launch Unity and load the downloaded automotive HMI template.
- Save this modified scene, as it will serve as the foundation for our project.
1.3 Download and import the ProtoPie Unity plugin
- Download the ProtoPie Unity Plugin.
- Double-click the downloaded package to import it into your Unity project.
💡 Important: Verify that the "ProtoPie" game object is present in your Unity scene. This object is crucial for handling all message mappings and interactions.
![Double-click the downloaded package to import it into your Unity project.](https://cdn.sanity.io/images/qyzm5ged/blog/a206f249df1576a1c4b6128c7329e9672dcec0b0-2350x1464.png/CleanShot-2024-07-01-at-21.55.57@2x.png)
Step 2. Configure the ProtoPie prototype
Now that we have installed the Unity plugin let's configure the ProtoPie prototype.
2.1 Download the Pie
This tutorial uses a basic ProtoPie prototype with various buttons (Drivetrain, Interior, Doors, Battery, Trunk, and Main View buttons). You can download the Pie here: Stage - Unity Vehicle 3D Main.
2.2 Set up Send & Receive functions
Assign Send responses and Receive triggers to each button in your ProtoPie prototype. This setup ensures that when a button is clicked, it sends a specific message to ProtoPie Connect, which then maps these messages to corresponding actions in Unity.
- For example, clicking the "Engine" button sends a
GoToEngineView
message. - Similarly, clicking the "Interior" button sends a
GoToInteriorView
message.
Repeat this configuration for all buttons. Once your prototype is fully configured, proceed to the next step.
![Configure the Pie by setting up Send & Receive functions.](https://cdn.sanity.io/images/qyzm5ged/blog/5f84a0e9abfd83afb6f678696a530d88ddd7e749-3205x2221.png/CleanShot-2024-07-02-at-17.25.59@2x.png)
Step 3. Configure message mapping
3.1 Create a new game object
In Unity, create a new game object and name it "ProtoPie.” This name is case-sensitive and crucial for the setup. This game object manages all the message mappings for you, eliminating the need to configure each Unity game object individually.
![In Unity, create a new game object and name it "ProtoPie.”](https://cdn.sanity.io/images/qyzm5ged/blog/6d4908c9eb78dd045e4087aae61eb91014fabba8-2348x1468.png/CleanShot-2024-07-01-at-21.57.58-2@2x.png)
3.2 Add the message interaction script
- Select the "ProtoPie" game object.
- Click on "Add Component" and search for "Message Interaction".
- Add the "Message Interaction" script to the "ProtoPie" game object.
Now that the plugin is enabled, we’re ready to start mapping.
![Add the "Message Interaction" script to the "ProtoPie" game object.](https://cdn.sanity.io/images/qyzm5ged/blog/b0b93e668efc286b64bf0d5960a5b550c36eca70-2352x1472.png/CleanShot-2024-07-01-at-22.04.48@2x.png)
3.3 Define the mapping table
- In the Unity plugin, create a mapping table to define how ProtoPie messages will be mapped to Unity actions. For example, messages like
GoToEngineView
andGoToInteriorView
will be included in this table. - Once the mapping table is defined, import it into the “Message Data” field in Unity. This step prepares the system for adding and executing the mappings.
Let’s look at an example of how to map the Main view.
- Choose the "Main" label from the mapping table, which already has a defined "Go to Main View" message.
- Specify that the message direction is from ProtoPie. This means that when ProtoPie sends a
GoToMainView
message, Unity will perform the corresponding action. - Add the specific action that Unity will execute when it receives the
GoToMainView
message. This is how the plugin maps ProtoPie messages to Unity actions.
Repeat this process for other buttons and messages, such as GoToEngineView
and GoToInteriorView
, mapping each message to its respective method in Unity. Once all mappings are complete, you can proceed to build your Unity project and integrate it with ProtoPie Connect for testing and refinement.
![Mapping messages inside Unity.](https://cdn.sanity.io/images/qyzm5ged/blog/84e30c05f0f85228080f4dcf51af070067d9bf3d-2348x1464.png/CleanShot-2024-07-01-at-23.05.08@2x.png)
Understanding the mapping process
In this tutorial, an interaction object within the Unity scene contains predefined game logic and several scripts, such as the CurrentDirectionController
script and the IVInputController
script. These scripts are typically created by Unity specialists or engineers to handle game mechanics.
We will use these methods to map the ProtoPie messages. For example, the CarInteractionController
script has several methods of controlling car animations, such as switching to the battery or interior view.
💡 Tip: Currently, the ProtoPie mapping table can only find the Invoke
code from parent objects, not child objects.
Step 4. Build the Unity project
Now that all mappings are complete, let’s build the Unity project.
- In Unity, go to
File
>Build Settings
. - Choose
WebGL
as the build platform and clickSwitch Platform
if it's not already selected. - Ensure all necessary configurations for WebGL are set. This includes adjusting Player settings and any other specific build settings required for your project.
- Add the scenes you want to include in the build by clicking
Add Open Scenes
. - Click
Build
and select a directory to save the build files. Unity will compile the project and create a folder containing all the necessary files for the WebGL build. - Once the build process is complete, locate and zip the build folder. This compressed file will be used to import the Unity project into ProtoPie Connect.
![Building the Unity project.](https://cdn.sanity.io/images/qyzm5ged/blog/636198bfac7e6bce64d0c5f6bff3f8194eb33221-2348x1466.png/CleanShot-2024-07-01-at-23.11.24@2x.png)
By following these steps, you will generate a WebGL build of your Unity project, which can then be embedded into ProtoPie Connect for interaction and testing.
💡 Tip: Before building, please make sure you have set the Compression Format
as Disabled
in the Player Settings
.
![Set the Compression Format as "Disabled" in the Player Settings.](https://cdn.sanity.io/images/qyzm5ged/blog/0a6d28314d29529be18173f162afdc376b91cbe6-2000x1177.png/disabled.png)
Step 5. Test the interaction in ProtoPie Connect
1. Download the 3 Pies below.
2. Launch ProtoPie Connect and open all 3 Pies in Stage View.
3. Insert a new Unity layer into the Stage View. This will be the layer where your Unity build will be embedded.
4. Reorder the layers as needed and configure the Unity layer to ensure proper interaction.
5. Import the WebGL build from Unity into the newly added layer in ProtoPie Connect.
![Import your Unity project on ProtoPie Connect’s Stage View.](https://cdn.sanity.io/images/qyzm5ged/blog/01378d4bef975a74ba8d47c72f04a1ac5fe29d0b-2130x1330.png/CleanShot-2024-07-02-at-16.17.54@2x.png)
6. Switch to full-screen mode for a better testing experience.
7. Click on the various buttons in ProtoPie and observe their interactions. Each button should trigger a corresponding message to Unity.
- For example, clicking the "Drivetrain" button should switch the Unity view to the drivetrain view.
- Clicking the "Main View" button should revert the view back to the main interface.
- Test other buttons, such as "Interior," "Doors," "Battery," and "Trunk," to ensure they correctly switch views in Unity.
8. In ProtoPie Connect, monitor the messages being sent and received. Ensure that each ProtoPie message corresponds to the appropriate Unity method.
![Monitor the messages being sent and received between Unity and ProtoPie.](https://cdn.sanity.io/images/qyzm5ged/blog/73372d7410eb8dee97cc2ede2d25ebeab6cb62dd-2134x1332.png/CleanShot-2024-07-02-at-16.19.44@2x.png)
💡 Tip: If the animation works well in Unity but doesn’t work in ProtoPie Connect, please go back to Unity, find a script called Message interaction
, and then change the code WebGLInput.captureAllKeyboardInput = false
to WebGLInput.captureAllKeyboardInput = true
.
![Ensure the code WebGLInput.captureAllKeyboardInput is set to true.](https://cdn.sanity.io/images/qyzm5ged/blog/69468bfd24267094e9f0111ccee66eab45461bc9-2000x1437.png/code.png)
Workflow for integrating Unity with ProtoPie
Below is our recommended workflow for integrating Unity with ProtoPie:
- Clearly outline the messages to be sent from ProtoPie and map them to corresponding events in Unity.
- Set up the defined messages within ProtoPie and map them to specific actions in Unity.
- Export your Unity project in a WebGL format suitable for embedding in ProtoPie Connect.
- Continuously test the integration and refine your design to ensure smooth interactions.
![Workflow for integrating Unity with ProtoPie.](https://cdn.sanity.io/images/qyzm5ged/blog/f74f9a8e2b778c699c85de0232e7a070626b996a-2000x1115.png/workflow.png)
Tips for an effective Unity-ProtoPie integration
- Ensure clear communication and set expectations between ProtoPie designers and Unity specialists (engineers or developers). Each will have their own workflows and projects, so early discussions on interaction fulfillment are crucial.
- Be mindful of specific configurations, such as disabling compression in WebGL settings and ensuring the Unity object is named "ProtoPie" (case-sensitive). These details are essential for smooth integration.
![Tips for effective Unity-ProtoPie integration.](https://cdn.sanity.io/images/qyzm5ged/blog/cb1b92d6a5c16866c41548bf9c8f4be415b2c921-2000x1115.png/tips.png)
Build and test interactive prototypes with Unity and ProtoPie
By following these steps, you can create a sophisticated 3D car demo using the ProtoPie Connect Unity Plugin. This integration allows for dynamic and interactive prototypes, enhancing your design and development process for applications in various fields, including automotive interfaces, game, VR, and medical technology.