The DataPrivacy
class configures the Unity Analytics service based on the player’s data privacy management choices.
NAMESPACE: UnityEngine.Analytics
public class DataPrivacy
The DataPrivacy
class automatically fetches the player’s data privacy status and configures the Analytics service accordingly.
使用 FetchPrivacyUrl()
函数来获取玩家个人数据管理页面的 URL。打开该 URL 即可为玩家提供管理其数据隐私设置的选项。
This page details the following functions:
准备 Data Privacy API 以供使用。
public static void Initialize()
This function creates a hidden GameObject and adds an instance of the DataPrivacy
class to it as a component.
On Unity 5.1 or earlier, call Initialize()
early in your application startup (ideally, right after you call UnityAnalytics.StartSDK (projectId)
. Newer versions of Unity call Initialize()
automatically.
获取玩家个人数据管理页面的 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. You can use Application.OpenURL()
to open the page.
该 URL 在短时间内有效。务必在打开 URL 之前即时获取 URL。
2018–11–05 Page published with limited editorial review
Removed Editor menu command for inserting the Data Privacy button. Added the Data Privacy Button prefab.
New feature in Unity 2018.1.
Removed FetchOptOutStatus function in 2018.3.