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.

Engine Integration

  1. Drag and drop a Streams prefab into GenvidSession as a child of the GenvidSession.

  2. The GenvidSession has a Streams section. Drag and drop your current Streams prefab into this field.

    A GenvidStreams object.
  3. Change the Ids Size to the number of game-data streams that you want to create.

  4. Open one element and give it a unique name in the Id field.

  5. Select a Framerate you want game data to be repeated and sent. (Optional if you don’t want data to be re-sent.)

  6. In the script that sends game data, create a public function that takes one string parameter.

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

    Note

    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:

    GenvidSessionManager.Instance.Session.Streams.SubmitGameDataJSON(streamId, gameData);
    
  9. 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.

  10. Create an instance of this class and store your data in it.

  11. Assign the data to the Submit function you used above.

  12. Drag and drop the object containing your game script with the new function in the On Submit Stream (String) element you added previously.

  13. From the dropdown list displaying No Function, select your game script and function created above.

    Dropdown list to get the function Streams with ID, framerate and callback set

See also

Streams Prefab