Unity Sample Integration

Warning

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

This release supports Unity versions 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 Application and exposes the same functionalities.

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

Genvid SDK deactivation

Running your game without the Genvid stack active will cause errors. If you need to test in the editor without the stack running, you can disable the Genvid SDK directly from the editor.

  1. Select the GenvidSessionManager object.
  2. Click the Activate SDK checkbox to disable it.
  3. Proceed to the second scene to deactivate the GenvidSessionManager object, if needed.

How to run the sample

This guide assumes that your system is already properly configured to run the Genvid Tutorial sample.

  • Your config file is properly set up with a working YouTube account. (See Genvid Configuration for more information.)
  • You can successfully run the Genvid services. (See Local Environment Usage for more information.)

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
    
  2. Install the package in the project.

    py unity.py prepare
    
  3. 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.

    Available options:

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

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

  4. Launch the game with all of the required Genvid services:

    genvid-sdk start
    

    Use the command genvid-sdk open web to see the website.

    If you want to stop the stack, use the command genvid-sdk stop.

Genvid Unity Package

The samples/unity/package/genvid.unitypackage file 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
This is our main native DLL for Windows (32-bit and 64-bit versions). It is required for integrating 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 (32-bit and 64-bit versions) 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

These folders contain scripts and prefabs for integrating Genvid more easily. We use them in our sample integration, but they aren’t required. You can replace them in your project.

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

Genvid/Editor
This folder contains scripts that add some tools to control the Genvid Stack from the Unity Editor. They create 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

The Unity Installer only installs the C# tools by default. You need to install C++ support separately to build the Unity package.

Installing the package

We use a Python script to install the package for our sample. (py unity.py prepare) You can also manually add the Genvid SDK to your Unity project.

  1. Select Assets ‣ Import Package ‣ Custom Package.
  2. Click the genvid.unitypackage located in the samples/unity/package/ folder.

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.