Unity Analytics 和欧盟一般数据保护条例 (GDPR)
Analytics 指标、细分段和术语

Unity Analytics DataPrivacy API

DataPrivacy 类根据玩家的数据隐私管理选项来配置 Unity Analytics 服务。

NAMESPACE: UnityEngine.Analytics

    public class DataPrivacy

DataPrivacy 类自动获取玩家的数据隐私状态,并相应配置 Analytics 服务。

使用 FetchPrivacyUrl() 函数来获取玩家个人数据管理页面的 URL。打开该 URL 即可为玩家提供管理其数据隐私设置的选项。

This page details three functions:

Initialize()

准备 Data Privacy API 以供使用。

声明

    public static void Initialize()

详细信息

此函数会创建一个隐藏的游戏对象,并会将 DataPrivacy 类的实例作为组件添加到该游戏对象。

在 Unity 5.1 或更早版本中,应在应用程序启动时尽早调用 Initialize()(理想情况下是在调用 UnityAnalytics.StartSDK (projectId) 之后立即进行)。更高版本的 Unity 会自动调用 Initialize()

FetchOptOutStatus(Action<bool>)

Fetches the player’s current opt-out status and configures the Unity Analytics service.

声明

    public static void FetchOptOutStatus(Action<bool> optOutAction = null)

参数

  • [optional] Action<bool> optOutAction — The Action object to invoke when Unity has fetched the player’s opt-out status. The boolean parameter passed to your Action is true if the player has opted out of personal data collection, and false if they have not.

详细信息

The function configures the Analytics service as appropriate for the player’s data collection choices. Unity caches the status for use when the player’s computer or device is offline.

Unity calls FetchOptOutStatus() automatically when your game launches. You should also call the function when the player returns to your app after closing the data privacy management URL, to immediately apply any changes they made while on that page.

You can also use FetchOptOutStatus() and pass an Action<bool> function parameter to get a player’s opt-out choice. The plug-in invokes the optOutAction function you provide when the network fetch request is complete. The boolean argument passed to your action is true when the player has opted out and false, if they have not. If the network request for the player’s status fails, Unity calls your optOutAction function with the cached value (or false, if the status has never been set).

    void OnOptOutStatus(bool optOut)
    {
        if(optOut)
        {
            Debug.Log("Player has opted-out of personal data collection.");
        }
    }

    // ...
    DataPrivacy.FetchOptOutStatus(OnOptOutStatus);

FetchPrivacyUrl(Action<String>, Action<String>)

获取玩家个人数据管理页面的 URL。

声明

    public static void FetchPrivacyUrl(Action<string> success, Action<string> failure = null)

参数

  • Action<String> success — 成功获取该 URL 时要调用的 Action 对象。传递给 Action 的字符串包含该 URL。

  • [optional] Action<String> failure — Unity 无法获取该 URL 时要调用的 Action 对象。传递给 Action 的字符串包含失败原因。

详细信息

Open the URL passed to your success function in a browser or webview to give the player the opportunity to manage their data protection options. Use Application.OpenURL() to open the page.

该 URL 在短时间内有效。务必在打开 URL 之前即时获取 URL。

Call FetchOptOutStatus() after the player returns to your game to apply any changes immediately. Otherwise, Unity applies any changes to data collection the next time the player launches your game.


  • 2018–05–18 页面已发布并只进行了有限的编辑审查
  • 删除了用于插入 Data Privacy 按钮的 Editor 菜单命令。添加了 Data Privacy Button 预制件。
  • Unity 2018.1 中的新功能
Unity Analytics 和欧盟一般数据保护条例 (GDPR)
Analytics 指标、细分段和术语