Class CustomEvent
Use this class to record Custom events that are specific to your game, without creating a specific sub-class of Event.
The CustomEvent class is provided as a low-effort way to migrate to the new RecordEvent(...) API from the dictionary-based approach used by prior versions of the Analytics SDK (the CustomData(...) API). CustomEvent instances can be treated as write-only dictionaries through collection initialization and the string indexer, meaning the code changes to migrate to the new API should be minimal.
For more information about custom events, see the documentation page: https://docs.unity.com/ugs/en-us/manual/analytics/manual/record-custom-events
Implements
Inherited Members
Namespace: Unity.Services.Analytics
Assembly: Unity.Services.Analytics.dll
Syntax
public class CustomEvent : Event, IEnumerable
Constructors
CustomEvent(string)
Creates a new CustomEvent instance for the given event type that you can populate with the relevant data.
Declaration
public CustomEvent(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The name of the schema this event will match. |
Properties
this[string]
Sets the parameter key to the given value. The value's type must match the type defined in the event schema. Only primitive values (string/int/bool/float) are acceptable.
Declaration
public object this[string key] { set; }
Parameters
| Type | Name | Description |
|---|---|---|
| string | key | The name of this parameter, as defined in the event schema. |
Property Value
| Type | Description |
|---|---|
| object |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown if an unsupported type is given for the value. |
Methods
Add(string, object)
Sets the parameter key to the given value.
Declaration
public void Add(string key, object value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | key | The name of this parameter, as defined in the event schema. |
| object | value | The value to store for this parameter, of the type defined in the event schema. Only primitive values (string/int/bool/float) are acceptable. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown if an unsupported type is given for the value. |
GetEnumerator()
Provided to allow collection initialization, not intended for public use.
Declaration
public IEnumerator GetEnumerator()
Returns
| Type | Description |
|---|---|
| IEnumerator | An enumerator over all the key/value pairs written to this event. |