Let’s look at a code snippet for a star-rating Rive file. If a reported event’s name is Star, the rating property of type float and a message of type string are retrieved from the event data (custom properties).
Copy
Ask AI
private void HandleRiveEventReported(ReportedEvent reportedEvent){ Debug.Log($"Event received, name: \"{reportedEvent.Name}\", secondsDelay: {reportedEvent.SecondsDelay}"); if (reportedEvent.Name == "Star") { // You can access properties directly and cast them if (evt.Properties.TryGetValue("rating", out object rating)) { float ratingValue = (float)rating; Debug.Log($"Rating: {ratingValue}"); } if (evt.Properties.TryGetValue("message", out object message)) { string messageValue = message as string; Debug.Log($"Message: {messageValue}"); } /* // For Typesafe access to properties, use the TryGet* methods for (uint i = 0; i < evt.PropertyCount; i++) { ReportedEvent.Property property = evt.GetProperty(i); if (property.Name == "rating" && property.TryGetNumber(out string ratingValue)) { Debug.Log($"Rating: {ratingValue}"); } else if (property.Name == "message" && property.TryGetString(out string messageValue)) { Debug.Log($"Message: {messageValue}"); } } */ }}
Properties that can be read are bool, string, and float.
Access a dictionary of all properties with: reportedEvent.Properties.