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 using 3 DLL files. In this page, we will use our own sample to explain how to integrate the API directly into your project and how to use it. The Unity sample is similar to our D3D11 tutorial sample and exposes the same functionalities.

We also provide a prefab with scripts to directly access the Genvid SDK 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. Files needed
  3. Game script files
  4. Prefab 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. Build the project and the website:
py unity.py build

Note that there are now several build options, so you can use:

  • -b: Build in 32 bit
  • -d: Build in debug
  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.

Files needed

Three files are currently required to be integrated into your project to fully use our SDK without any issues. If you want to run the current sample, you don’t need to copy the files in the sample. By using py unity.py build, you can build the project and run it without having to manually copy any file.

Genvid.dll

This is the file created by our Native SDK and it is used to make all the calls related to Genvid. The Genvid SDK includes both a 32-bit and 64-bit version of the library for the Windows platform. Make sure to use the proper one related to the compilation of your application.

This file needs to be placed inside the Plugins folder of your project. For the current sample, we placed the files inside an x64 and x86 folder depending of the library version. The command script of the project handles this for you when you run local.py run-script build.

As a developer, you will not need to call any function from this DLL directly since we created a C# wrapper integrating all the functions needed from it to simplify the process.

GenvidPlugin.dll

This is a file created by the GenvidPlugin project integrated in the Unity sample project folder. This file is taking care of making calls to do the video capture.

This file needs to be placed inside the Plugins folder of your project. For the current sample, we placed the files inside an x64 and x86 folder depending of the library version. The command script of the project handles this for you when you run local.py run-script build.

GenvidSDKCSharp.dll

This is a file that is used to make all the calls to the Genvid.dll. This file is a C# wrapper of the Genvid C SDK, so all the proper conversions are handled by this dll.

This file needs to be placed inside the Plugins folder of your project. In our sample, we placed this file inside a Genvid folder which is located inside Plugins.

Game script files

Some additional script files are used for the Unity sample, so we made up a list for each and what are their purpose.

GenvidActivation.cs

This is a file that is used to create a dynamic object that is carried from one scene to another. This object is used to determine if the Genvid SDK initialization process has been done when proceeding to another scene.

This file is placed inside the Assets/Scripts folder of the sample project.

Game.cs

This is a file that is used to perform the camera and scene changes. It is also used to perform the various interactions with the Genvid prefab and the scene.

This file is placed inside the Assets/Scripts folder of the sample project.

MovementCube.cs

This is a file that is used to move the objects on the scene. It is also used to update popularity and colors of the associated game object.

This file is placed inside the Assets/Scripts folder of the sample project.

CubeColor.cs

This is a file that is used to format the cube color and cube name in the same class.

This file is placed inside the Assets/Scripts folder of the sample project.

CubePopularity.cs

This is a file that is used to format the cube popularity and cube name in the same class.

This file is placed inside the Assets/Scripts folder of the sample project.

CubeData.cs

This is a file that is used to format the cube location, name, color, popularity and leader selection in the same class.

This file is placed inside the Assets/Scripts folder of the sample project.

Build.cs

This is a file that is used to build the unity sample project via the python script in various configurations.

This file is placed inside the Assets/Scripts/Editor folder of the sample project.

Prefab files

Several files are located in the folder prefabsPackage for the Unity samples. The current Unity sample runs with the prefab activated. See Unity prefab for the Genvid SDK for more information.