Version: 2023.1

Analytics.ResumeInitialization

切换到手册
public static Analytics.AnalyticsResult ResumeInitialization ();

描述

继续 Analytics 初始化。

默认情况下,Unity 会在应用程序启动时自动初始化 Analytics,这涉及将数据发送到 Unity Analytics 服务。要防止或延迟初始化,请在编辑器脚本中将 Analytics.AnalyticsSettings.InitializeOnStartup 设置为 false。还可以在运行时将 Analytics.Analytics.InitializeOnStartup 设置为 false,在这种情况下,Unity 会暂停其当前状态的初始化,直到您调用 ResumeInitialization

See Also: Analytics.AnalyticsSettings.InitializeOnStartup, Analytics.Analytics.InitializeOnStartup.

using System;
using UnityEngine;

#if ENABLE_CLOUD_SERVICES_ANALYTICS using UnityEngine.Analytics;

public class DataPrivacyOptInFlow { [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)] static void InitStepOne() { Analytics.initializeOnStartup = false; }

// Call this when the user has given permission to collect data public void UserHasOptedIntoDataCollection_LetsResumeAnalyticsInitialization() { Analytics.ResumeInitialization(); } } #endif