Genvid Events

The GenvidEvents prefab object trigger your callback when an event occurs on the website. You can have multiple events for the same GenvidEvents object. You need to modify the size of the Ids to have the number of events required for your application. Each element of this array contains several properties that can be modified:

Genvid Events inspector view
Id
The name of the event. Make sure to use a unique name compared to the other events used in your application.

On Event Triggered (String eventId, EventResult[] results, Int32 size, IntPtr data)

The On Event Triggered function executes when the event triggers from the website.

  • eventId is the unique ID for the event.
  • results is a list of the possible results from the event.
  • size is the number of results available.
  • data is a unique pointer related to the specific callback.

Here’s an example on how we performed the color change for the sample:

    public void OnEventChangeColor(string eventId, GenvidSDK.EventResult[] results, int numResult, IntPtr userData)
    {
        string cubeName = results[0].key.fields[0];
        var cube = m_Cubes.Find(o => o.name == cubeName);

        string cubeColor = results[0].key.fields[1];
        var color = m_NameToColors.Find(o => o.name == cubeColor);
        if (color != null && cube != null)
        {
            changeColorCube(cube, color);
        }
        else
        {
            Debug.LogError("Can't change cube" + cubeName + " with color: " + cubeColor);
        }
    }