自定义事件
Analytics Event Tracker

自定义事件脚本

As an alternative to using the AnalyticsEventTracker component, you can send Custom Events directly via script by calling AnalyticsEvent.Custom:

// 引用 Unity Analytics 命名空间
using UnityEngine.Analytics;

// 在玩家触发自定义事件的任何位置使用此调用
AnalyticsEvent.Custom(string customEventName, IDictionary<string, object> eventData);

Analytics.CustomEvent 输入参数

Name Type 描述
customEventName string Name of the custom event. The name cannot include the prefix “unity”, which is reserved for internal Unity Analytics events.
eventData dictionary Additional parameters sent to Unity Analytics at the time the custom event was triggered. eventData keys cannot include the prefix “unity”, which is reserved for internal Unity Analytics events.

以下示例在玩家在关卡中找到秘密位置时发送自定义事件:

public void ReportSecretFound(int secretID){
    AnalyticsEvent.Custom("secret_found", new Dictionary<string, object>
    {
        { "secret_id", secretID },
        { "time_elapsed", Time.timeSinceLevelLoad }
    });
}

  • 2018–03–02 Page published with no editorial review

  • 截至 2018–03–02,服务与 Unity 5.2 之后的版本兼容,但是版本兼容性可能会发生变化

  • 5.2 中的新功能

  • 标准事件可作为 Unity 插件包添加进来。

自定义事件
Analytics Event Tracker