Last active
September 5, 2023 13:40
-
-
Save akingdom/bc9dba0d61e6a60546a877c4ac81c16f to your computer and use it in GitHub Desktop.
Disables sending of device details, etc. to Unity.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Attach this to any GameObject in the first scene loaded (e.g. the camera). | |
* | |
* You can use Charles Proxy to monitor network calls from your game https://support.unity3d.com/hc/en-us/articles/115002917683-Using-Charles-Proxy-with-Unity | |
* | |
* You shouldn't need this if Analytics is disabled in the Services window (which does the same thing as the old Disable HW Stats flag in earlier versions of the Unity Editor). The Analytics Package is not used if Analytics is not enabled. | |
* | |
* Ref: | |
* https://forum.unity.com/threads/unity-iap-without-analytics-for-kids-games.689143/ | |
* https://forum.unity.com/threads/what-happened-to-disable-hw-statistics.961060/ | |
* https://gist.github.com/yasuyuki-kamata/6e65988e817507efff85dba900d5ce30 | |
* | |
* License: | |
* CC0 | |
*/ | |
using UnityEngine; | |
[AddComponentMenu("Analytics/Disable Analytics")] | |
public class DisableAnalytics : MonoBehaviour | |
{ | |
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)] | |
public static void OnRuntimeMethodLoad() | |
{ | |
UnityEngine.Analytics.Analytics.enabled = false; | |
UnityEngine.Analytics.Analytics.deviceStatsEnabled = false; | |
UnityEngine.Analytics.Analytics.limitUserTracking = true; | |
try { UnityEngine.Analytics.PerformanceReporting.enabled = false; } | |
catch (System.MissingMethodException) { } // broken binding fixed after Unity 2017.2 | |
#if UNITY_2018_3_OR_NEWER | |
UnityEngine.Analytics.Analytics.initializeOnStartup = false; | |
#endif | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment