Skip to content

Instantly share code, notes, and snippets.

@desmondfernando
Last active December 3, 2021 08:46
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save desmondfernando/32b6e12d2c9fca9ff00a1608161b6184 to your computer and use it in GitHub Desktop.
Save desmondfernando/32b6e12d2c9fca9ff00a1608161b6184 to your computer and use it in GitHub Desktop.
Code snippet to disable HW statistics reporting. NOTE only works in the Editor not for runtime! Unity Pro only
var type = Type.GetType( "UnityEditor.PlayerSettings,UnityEditor" );
if ( type != null )
{
var propertyInfo = type.GetProperty( "submitAnalytics", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static );
if ( propertyInfo != null )
{
{
var value = (bool)propertyInfo.GetValue( null, null );
Debug.LogFormat( "PlayerSettings.submitAnalytics {0}", value );
}
if ( propertyInfo.CanWrite )
{
propertyInfo.SetValue( null, false, null );
var value = (bool)propertyInfo.GetValue( null, null );
Debug.LogFormat( "PlayerSettings.submitAnalytics {0}", value );
}
}
}
@desmondfernando
Copy link
Author

Use this snippet to disable HW statistics reporting. I use this within my CI build scripts.

PlayerSettings.submitAnalytics is not public so you need to use reflection in order to modify.

https://docs.unity3d.com/Manual/class-PlayerSettingsStandalone.html

@phamtanlong
Copy link

Nice, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment