customEventName | 自定义事件的名称。名称不能包含前缀“unity”- 这是一个保留关键字。 |
eventData | 触发自定义事件时发送至 Unity Analytics 的其他参数。字典键不能包含前缀“unity”- 这是一个保留关键字。 |
自定义事件(可选)。
Unity Analytics allows you to track specific events within your game. By configuring a series of Custom Events within your game, you can create your own Funnel Analysis to observe your players' game behavior. Good places to put custom events include: milestones, new levels, Scene transitions, etc.
除了跟踪自定义事件以外,Unity Analytics 还允许您传入与事件相关的自定义维度(字典)。这些自定义维度主要用于了解实现自定义事件时用户的其他规格。
using System; using System.Collections.Generic; using UnityEngine; using UnityEngine.Analytics;
public class GameLoginMonoBehaviour : MonoBehaviour { public void OnGameOver() { int totalPotions = 5; int totalCoins = 100; Analytics.CustomEvent("gameOver", new Dictionary<string, object> { { "potions", totalPotions }, { "coins", totalCoins } }); } }
自定义事件(可选)。
using System; using System.Collections.Generic; using UnityEngine; using UnityEngine.Analytics;
public class GameLoginMonoBehaviour : MonoBehaviour { public void OnGameOver() { Analytics.CustomEvent("gameOver"); } }
自定义事件(可选)。
using System; using System.Collections.Generic; using UnityEngine; using UnityEngine.Analytics;
public class GameLoginMonoBehaviour : MonoBehaviour { public void OnGameOver(Vector3 v) { Analytics.CustomEvent("gameOver", v); } }