Kontrol apakah layanan Analytics diaktifkan pada runtime.
Menyiapkan properti ini untuk palsu pada runtime menonaktifkan layanan Analytics. Anda dapat mengatur properti ini untuk benar untuk layanan Analytics yang dapat diandalkan, tetapi hanya jika Analytics diaktifkan ketika proyek dibangun.
Jika Analytics tidak diaktifkan ketika proyek dibangun, Anda tidak dapat menggunakan pengaturan ini untuk mengaktifkannya kapan saja.
using System; using UnityEngine;
#if ENABLE_CLOUD_SERVICES_ANALYTICS using UnityEngine.Analytics;
public class DataPrivacyOptInFlow { [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)] static void InitStepOne() { Analytics.initializeOnStartup = false; }
public void EnableAnonymizingData() { Analytics.limitUserTracking = true; }
// Call this when the user has given permission to collect data public void UserHasOptedIntoDataCollection_LetsResumeAnalyticsInitialization() { Analytics.ResumeInitialization(); }
// Call this when the user has given limited data collection permission public void UserHasOptedIntoLimitedDataCollection_LetsResumeAnalyticsInitialization() { EnableAnonymizingData(); Analytics.ResumeInitialization(); }
// Call this when the user doesn't want any data collection. public void UserHasOptedOutOfAllDataCollection() { // Don't call ResumeInitialization // But disable Analytics so the code knows to shutdown DisableAnalyticsCompletely(); }
// If you want to disable Analytics completely during runtime public void DisableAnalyticsCompletely() { Analytics.enabled = false; Analytics.deviceStatsEnabled = false; PerformanceReporting.enabled = false; } } #endif