Unity Cube Sample
This section walks you through setting up and running the Unity Cube Sample. Start here to get a quick introduction to what the integration process entails before moving forward with your own project.
This release is compatible with all Unity-supported LTS versions.
Important
Beta versions of the Unity engine are not supported.
Integrating the Genvid MILE SDK into your Unity project is a simple process. We provide a Unity package containing the 3 DLLs required and the scripts and prefab for using it.
You can find the package under
/engine-integration/unity/genvid_sdk.unitypackage
.
In this section, we use our own sample to explain how to integrate the API into your project and how to use it. The Unity sample is similar to our D3D11 DirectX Sample Application and exposes the same functionalities.
How to Run the Unity Sample
This guide assumes that your system is already properly configured to run the Genvid DirectX sample and that you can run the Genvid services. For information on running the services, see Start a Local Cluster.
Using a Local Cluster
Install the package in the project.
Follow the Unity asset documentation to import the package into the project.
Build the project.
Follow the Unity publishing documentation to build the project using the editor. When prompted to choose a name and a location to save the project, create a folder named
Build
inside the/app
folder. Keep the project name as it is.Set the environment variable.
Set the GENVID_UNITY_PROJECT_DIR environment variable to your project path (the path containing the
/app
folder) so that Nomad can load the template files.Prepare the Local Cluster with the basic services for the SDK:
genvid-sdk setup # Create the Local Cluster. genvid-sdk clean-config # Remove any previously loaded sample configurations. genvid-sdk load-config-sdk # Configure the basic services for the SDK.
Load the Unity sample job-template and configuration.
From the Unity sample root folder, run:
genvid-sdk load-config config --with-consul-template --job-template-dir templates/local
Load the sample website.
The Genvid MILE SDK includes a sample website which lets you be a spectator of your own stream. See the Web Sample section for more information.
To load the sample website, navigate to the folder
samples/cube/web
and run the following commands:py web.py build py web.py load
Launch the sample with all of the required Genvid services:
genvid-sdk start
Open the website from the Cluster-UI OR with the genvid-sdk command:
genvid-sdk open web
When you’re finished, stop the stack:
genvid-sdk stop
Using a Cloud Cluster
If you haven’t already, start by building the project and settting the GENVID_UNITY_PROJECT_DIR environment variable to your project path as described in the Using a Local Cluster section.
Package the build contents:
genvid-sdk package app/build -d images -n unity_Cube
Upload the content:
genvid-sdk -c {cluster-id} upload-images unity_Cube -d images --update-config
Prepare the Cloud Cluster with the basic services for the SDK:
genvid-sdk -c {cluster-id} clean-config # Remove any previously loaded sample configurations. genvid-sdk -c {cluster-id} upload-images-sdk -u; # Upload the SDK images and update the cluster configurations. genvid-sdk -c {cluster-id} setup # Set up the SDK. genvid-sdk -c {cluster-id} load-config-sdk # Load job definitions of the SDK configuration into the cluster.
Load the Unity sample job-template and configuration.
From the Unity sample root folder, run:
genvid-sdk -c {cluster-id} load-config config --with-consul-template --job-template-dir templates/cloud
Build, upload, and load the sample website:
py web.py build-cloud py web.py -c {cluster-id} upload-images --update-config py web.py -c {cluster-id} load
Launch the sample with all of the required Genvid services:
genvid-sdk -c {cluster-id} start
Open the website from the Cluster-UI OR with the genvid-sdk command:
genvid-sdk -c {cluster-id} open web
When you’re finished, stop the stack:
genvid-sdk -c {cluster-id} stop
Game Script Files
You can find additional script files we use for the Unity sample in
the Assets/Scripts
folder of the project.
Game.cs
This file performs the camera and scene changes. It also performs the various interactions with the Genvid prefab and the scene.
MovementCube.cs
This file moves the objects in the scene. It also updates popularity and colors of each associated game object.
CubeColor.cs
This file formats the cube color and cube name in the same class.
CubeColorChanged.cs
This file formats the cube color into a list which is needed for JSON parsing.
CubePopularity.cs
This file formats the cube popularity and cube name in the same class.
CubeData.cs
This file formats the cube location, name, color, popularity, and leader selection in the same class.
Editor/Build.cs
This file builds the Unity sample project via the Python script in various configurations.