Unity prefab for the Genvid SDK¶
Warning
This feature is currently in beta. The prefab is fully functional, but we expect to make some changes in the future to improve the user experience. Your feedback on this process is welcome.
For an even easier integration of the Genvid SDK into Unity, we created a prefab to easily integrate the SDK into your project.
This section covers documentation related to the use of the prefab with a description for each files available and a step by step description on how to use these properly.
Note that the prefab only works if you have the files needed indicated
in the Unity sample project: Genvid.dll
, GenvidPlugin.dll
and
GenvidSDKCSharp.dll
. If you need more information about these
files, please go to the section Files needed.
- Files included in the prefab
- Genvid Manager
- Stream creation
- Data management - Game data sending
- Data management - Annotation
- Data management - Notification
- Event callback
- Command callback
Files included in the prefab¶
All the files included in the prefab are below. You can use the game object to drag and drop on your scene or directly use the script if you prefer.
GenvidPrefab/Genvid Management
This object is used to manage all your Genvid SDK objects on the scene.
GenvidPrefab/GenvidManagement.cs
This script is used to manage all your Genvid SDK objects on the scene.
GenvidPrefab/Streams/AudioStream
This object is used to create a new audio stream.
GenvidPrefab/Streams/StreamScripts/AudioStream.cs
This script is used on the object AudioStream to manage the Genvid SDK in Unity.
GenvidPrefab/Streams/GeneralStream
This object is used to create a new stream used for data (not video or audio related).
GenvidPrefab/Streams/StreamScripts/GeneralStream.cs
This script is used to create a new stream used for data (not video or audio related).
GenvidPrefab/Streams/VideoStream
This object is used to create a new video stream.
GenvidPrefab/Streams/StreamScripts/VideoStream.cs
This script is used to create a new video stream.
GenvidPrefab/Data/AnnotationSend
This object is used to send an annotation.
GenvidPrefab/Data/DataScripts/AnnotationManagement.cs
This script is used to send an annotation.
GenvidPrefab/Data/DataToSend
This object is used to send data along the stream.
GenvidPrefab/Data/DataScripts/DataManagementElement.cs
This script is used to send data along the stream.
GenvidPrefab/Data/DataToSend_List
This object is used to gather several DataToSend objects as a list to be sent along the stream.
GenvidPrefab/Data/DataScripts/DataManagement.cs
This script is used to gather several DataToSend objects as a list to be sent along the stream.
GenvidPrefab/Data/NotificationSend
This object is used to send a notification.
GenvidPrefab/Data/DataScripts/NotificationManagement.cs
This script is used to send a notification.
GenvidPrefab/Callback/CommandCallback
This object is used to create a command callback.
GenvidPrefab/Data/CallbackScripts/CommandCallbackManagement.cs
This script is used to create a command callback.
GenvidPrefab/Callback/EventCallback
This object is used to create an event callback.
GenvidPrefab/Data/CallbackScripts/EventCallbackManagement.cs
This script is used to create an event callback.
Genvid Manager¶
The main object of the prefab. You will need to have this object
as the parent of any Genvid prefab objects. Each object is verifying
if Genvid SDK Active
is selected on the root parent object. This
object contains various properties that can be activated depending
on your needs:
Genvid SDK Active
This allows you to quickly activate/deactivate the Genvid SDK. Each object placed as child of this object will verify if this option is activated before doing any action.
Keep Alive
When checked, this option prevents the object from being destroyed (DontDestroyOnLoad(this)). This is useful to keep the video stream intact when changing scene along any other stream you would not want to re-create.
Initialize SDK
When checked, this option performs the initialize process for the Genvid SDK when starting the application (Awake). This needs to be done once in your application if you want to activate the Genvid SDK.
Check Events
When checked, this option performs a CheckForEvents at every frame (FixedUpdate). This is needed if you want to trigger any eventCallback and commandCallback in your scene.
Destroy SDK
When checked, this option perfoms the Terminate when the object is destroyed (OnDestroy). This is needed when you are closing your application to make sure to terminate all the Genvid SDK processes.
Stream creation¶
This section will cover how to create the various streams by using the prefab.
Audio stream creation¶
An AudioStream
object is needed to perform the audio capture of
your application and you only need one. You just need to drag and drop
the AudioStream
prefab object into your scene inside a
GenvidManager
object so that the GenvidManager
object is the
parent of this object. Simply write a name for the Stream Name
and
now your application is capturing the audio for your stream. We
recommend that you keep your GenvidManager object alive with the
Keep Alive
option to prevent any interruption in the audio when
changing scene instead of re-creating a new AudioStream
object on
the next scene.
Video stream creation¶
A VideoStream
object is needed to perform the video capture of
your application (normally only one is needed). You just need to drag
and drop the VideoStream
prefab object into your scene inside a
GenvidManager
object so that the GenvidManager
object is the
parent of this object. Simply write a name for the Stream Name
and
now your application is capturing the video for your stream. We
recommend that you keep your GenvidManager object alive with the
Keep Alive
option to prevent any interruption in the video when
changing scene instead of re-creating a VideoStream
object on the
next scene.
You can now also capture the video stream directly from a camera of your
choice without the HUD. Simply click on the Capture Camera
checkbox
and write the name of the camera that you want to capture the video from
in the Camera Name
field. You can also, at any time, change the camera
used for recording from this prefab by accessing the object public property
m_cameraName
and change it to the value of your choice. In the event
you would change scene and keep the same prefab object for the video capture,
the prefab will revert back to the initial camera name that was entered on
the prefab. You can modify this public property named m_initCameraName
in case you use a different name for your camera in the next scene.
Non video/audio stream creation¶
GeneralStream
objects are normally used for game data purposes
(submitting game data, sending annotation, sending notification). You
just need to drag and drop the GeneralStream
prefab object into
your scene inside a GenvidManager
object so that the
GenvidManager
object is the parent of this object. Simply write a
name for the Stream Name
and now your stream is ready to go. We
recommend that you keep your GenvidManager
object alive with the
Keep Alive
option to prevent any interruption in the stream when
changing scene instead of re-creating a stream on the next scene.
Data management - Game data sending¶
The game data sending process is divided with two objects:
DataToSend_List and DataToSend. The DataToSend
object is used for
single data element and DataToSend_List
is used to regroup various
DataToSend
objects together. These objects allow you to format
your data in a customised format and allows for multidimensional
arrays.
A DataToSend_List
object contains these parameters:
Stream Name
The game data stream associated with it (if you used the prefab, it would be aGeneralStream
Stream Name
).
Submit Data
When checked, this option sends the game data associated to this object every frame (FixedUpdate).
Data Name
This adds a specific name to the data that will be sent. It’s normally used when you have multiple lists in your data block and you want an easier way to detect the data needed.
Debug Display Json
When checked, the Unity application displays the JSON formatted data from the object every frame (FixedUpdate) via Unity Debug.LogError().
Place Inside Brace
When checked, the data from this object is placed inside braces (one for the start of the data and one for the end). This is useful when you have several lists inside the same data block that needs to have some sections divided.
A DataToSend
object contains these paremeters:
Stream Name
The game data stream associated with it (if you used the prefab, it would be aGeneralStream "Stream Name"
).
Object Reference
This is the object where theVariable To Get
variable needs to be located.
Script Name
This is the name of the script attached to the Object Reference where the Variable To Get variable is located.
Variable To Get
Name of the variable that needs to be obtained at every frame (FixedUpdate).
Submit Alone
When checked, this option sends the game data associated to this object every frame (FixedUpdate).
Data Name
This adds a specific name to the data that will be sent. It’s normally used when you have multiple data elements in the same data block and you want an easier way to detect the data you are looking for.
Debug Display Json
When checked, the Unity application displays the JSON formatted data from the object every frame (FixedUpdate) via UnityDebug.LogError()
.
Data management - Annotation¶
AnnotationSend
objects are used to send annotations to the stream
associated with them. This is used to send game data to the stream at
the appropriate moment instead of every frame. You just need to drag
and drop the AnnotationSend
object into your scene inside a
GenvidManager
object so that the GenvidManager
object is the
parent of this object. Write a name for the Stream Name
that is
related to a GeneralStream
that was created and afterwards, you
need to either add DataToSend
and/or DataToSend_List
inside
your AnnotationSend
object to create the data associated to the
annotation. Once everything is created properly, you will need to
call SubmitAnnotation(Int64,String,String) from the object to
send the annotation when you need to.
Data management - Notification¶
NotificationSend objects are used to send notification to the stream
associated with them. A notification is sent every time the associated
data has been modified. The prefab compare the data every frame
(FixedUpdate) and submit the notification when the value has been
changed. You just need to drag and drop the NotificationSend
object into your scene inside a GenvidManager
object so that the
GenvidManager
object is the parent of this object. Write a name
for the Stream Name
that is related to a GeneralStream
that
was created and afterwards, you need to either add DataToSend
and/or DataToSend_List
inside your AnnotationSend
object to
create the data associated to the notification.
Event callback¶
EventCallback
objects are used to trigger actions in the game when
the users are interacting with the stream. A reduce map is used to filter the number of requests. You just need to
drag and drop the EventCallback
prefab object into your scene
inside a GenvidManager
object so that the GenvidManager
object
is the parent of this object. You need to fill in various parameters
afterwards to make it work properly:
Event Summary Name
This is the name for your Event Summary for the subscribe process. We suggest you use a unique event summary name for eachEventCallback
that needs to be created.
Associated Object
This is the object where theEventCallback
will search for theEvent Callback Name
method.
Script Name
This is the name of script attached to theAssociated Object
where theEvent Callback Name
method is located.
Event Callback Name
This is the method that will be called when theEvent Callback
is triggered. This callback needs to be using the same structure as this EventSummaryCallback.
User Data Name
This is the User Data that is sent along the subscribe and received in yourEvent Callback Name
method. This User Data needs to be inside the same script as that of theScript Name
.
It is also important to make sure that a CheckForEvents is
performed every frame to be able to activate the EventCallback
. We
recommend that you activate the Check Events on the GenvidManager
root parent object. We also recommend that you destroy and re-create
your EventCallback from one scene to another. This will prevent the
stream users from calling a callback from an older scene and cause an
error to be displayed.
Command callback¶
CommandCallback
objects are used to trigger actions in the game
when the admin user is interacting with the stream. Commands are not
using map reduce since it is limited in term of user access (normally
via a login and password). You just need to drag and drop the
CommandCallback
prefab object into your scene inside a
GenvidManager
object so that the GenvidManager
object is the
parent of this object. You need to fill up various parameters
afterwards to make it work properly:
Command Name
This is the name for your Command for the subscribe process. We suggest you use a unique command name for eachCommandCallback
that needs to be created.
Associated Object
This is the object where theCommandCallback
will search for theCommand Callback Name
method.
Script Name
This is the name of script attached to theAssociated Object
where theCommand Callback Name
method is located.
Command Callback Name
This is the method that will be called when theCommand Callback
is triggered. This callback needs to be using the same structure as this CommandCallback.
User Data Name
This is the User Data that is sent along the subscribe and received in yourCommand Callback Name
method. This User Data needs to be inside the same script as theScript Name
one.
It is also important to make sure that a CheckForEvents is
performed every frame to be able to activate the
CommandCallback
. We recommend that you activate the Check Events
on the GenvidManager root parent object. We also recommend that you
destroy and re-create your CommandCallback from one scene to
another. This will prevent the admin user from calling a callback from
an older scene and cause an error to be displayed.