Add Data-Stream Prefabs to GenvidSession¶
Data streams from your game are synchronized with the audio and video streams, letting you create new kinds of interactivity for your viewers. This section walks you through setting up a data stream in the GenvidSesison prefab and creating a script function to work with the data stream.
Drag and drop a Streams prefab into GenvidSession as a child of the GenvidSession.
The GenvidSession has a Streams section. Drag and drop your current Streams prefab into this field.
Change the Ids Size to the number of game-data streams that you want to create.
Open one element and give it a unique name in the Id field.
Select a Framerate you want game data to be repeated and sent. (Optional if you don’t want data to be re-sent.)
In the script that sends game data, create a public function that takes one string parameter.
Drag and drop the object with your script into the On Submit Stream (String) box and select the public function that you created from the dropdown list. (Optional if you want your data to be re-sent.)
- Note that sometimes the String field is listed when doing this operation. Add the Id of the element into this field or this value will later override the invoke call.
In your public function you can use the data-sending call that you want from the prefab:
- SubmitAnnotation: Send the data to the website once at a specific time and don’t repeat.
- SubmitGateData: Send the data to the website at a specific time and do repeat.
- SubmitNotification: Send the data to the website immediately (no specific time) and don’t repeat. Note: submitting notifications has been moved to the GenvidSession prefab as notifications are not submitted over streams.
Be aware that these functions support sending binary or string data only. If you intend to send your data encoded in JSON, you can also feed SubmitAnnotationJSON, SubmitGateDataJSON, SubmitNotificationJSON with an object that is serializable in JSON, without you having to handle the serialization yourself.
Example of accessing the function from the GenvidSessionManager:
Create a class that will store your data.
Formatting the data into classes makes it easier to access it from the website. For example, we created a Camera class in the GameDataStreams script which we populated with members representing fields the website will need to access in order to upadte the placement of overlay elements.
Create an instance of this class and store your data in it.
Assign the data to the Submit function you used above.
Drag and drop the object containing your game script with the new function in the On Submit Stream (String) element you added previously.
From the dropdown list displaying No Function, select your game script and function created above.