Unity Sample Integration

Warning

Please note that if you deploy your sample to the cloud that you must be compliant with Unity’s Terms of Service related to server streaming. Please contact Unity for more information. Genvid is not responsible for your licensing terms with Unity.

Supporting version 5.6 and 2017.02.

Integrating the Genvid 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.

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 tutorial sample and exposes the same functionalities.

Genvid SDK activation

We added an option to disable the Genvid SDK inside the editor in the event you would need to test in the editor without the stack running. Simply select the GenvidSessionManager object and click on the Activate SDK checkbox to disable it. Make sure to proceed to the second scene to deactivate the GenvidSessionManager object if needed.

  1. How to run the sample
  2. Genvid Unity Package
  3. Game script files

How to run the sample

This guide assumes that your system is already properly configured to run the Genvid tutorial sample (see Tutorial), i.e., that your config file is properly set up with a working YouTube account (see Genvid Configuration) and that you can successfully run the Genvid services (see Local Environment Usage).

Before explaining about the files and methods used, let us explain how to run the Unity sample.

  1. Clean the cluster config and load the unity sample:
genvid-sdk clean-config
genvid-sdk load-config-sdk
py unity.py load
  1. Install the package into the project:
py unity.py prepare
  1. Build the project and the website:
py unity.py build

This imports the genvid-plugin.unitypackage available under samples/unity/package and builds the Unity project available under samples/unity/app.

  • -b: Build in 32 bit
  • -d: Build in debug

You can also do the import yourself by starting the project and building the project from the Genvid menu.

  1. Launch the game with all of the required Genvid services:
genvid-sdk start

You can see the website by doing genvid-sdk open web.

In the event you would want to stop the stack: genvid-sdk stop.

Genvid Unity Package

The samples/unity/package/genvid.unitypackage contains everything necessary to integrate the Genvid SDK into your game and adds editor tools for controlling the Genvid Stack.

Package contents

Plugins/x86/genvid.dll and Plugins/x64/genvid.dll
Our main native DLL, available in both 32-bits and 64-bits for Windows. This is the main DLL necessary to integrate the Genvid Services.
Plugins/GenvidSDKCSharp.dll
This is the C# wrapper around our Native SDK. It provides all the same functionalities as genvid.dll and lets you use our SDK through Unity Scripts.
Plugins/x86/GenvidPlugin.dll and Plugins/x64/GenvidPlugin.dll
This is our Unity Native Plugin which lets us enable direct access to the graphics device for optimal video capture. It is not mandatory for integrating Genvid, but allows more efficient video transfer to our SDK.
Plugins/Genvid/Editor/GenvidRESTCSharp.dll This is a wrapper

around our Toolbox REST API which allows control of the Genvid Stack from the Unity Editor. It depends on two external third party libraries: RESTCSharp Library and Newtonsoft JSON.Net Library.

We use version 8.0 of the Newtonsoft library, so it can be replaced with the JSON.Net for Unity assets.

Genvid/Scripts and Genvid/Prefabs/Genvid

A set of scripts and prefabs for integrating Genvid more easilty. We use them in our sample integration, but aren’t required. You can replace them in your own project.

We describe these prefabs and scripts in more detail in the Unity prefab for the Genvid SDK section.

Genvid/Editor
Scripts that add some tools to control the Genvid Stack from the Unity Editor. This creates a new Genvid panel available from the Unity menu under Windows -> Genvid. The tools aren’t mandatory but can help testing in both the Local Environment and the The Cloud Environment.

Building the package

The package source is available under samples/unity/package. You can use the package.py script to build the full Unity package. You must have the Microsoft C++ Compiler installed to build the Unity package.

Warning

Unity Installer only installed the C# tools by default. You’ll need to install the C++ support to make it works.

Installing the package

The package is installed via a Python script for our sample, but for another project, you can proceed to Assets ‣ Import Package ‣ Custom Package. Select the genvid.unitypackage located in the samples/unity/package/ folder and it will add the Genvid SDK into your project.

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