docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    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

    Inheritance
    object
    Event
    CustomEvent
    Implements
    IEnumerable
    Inherited Members
    Event.SetParameter(string, string)
    Event.SetParameter(string, bool)
    Event.SetParameter(string, int)
    Event.SetParameter(string, long)
    Event.SetParameter(string, float)
    Event.SetParameter(string, double)
    Event.SetParameter(string, DateTime)
    Event.Validate()
    Event.ParameterHasBeenSet(string)
    Event.Reset()
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    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.

    Implements

    IEnumerable
    In This Article
    Back to top
    Copyright © 2026 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)