如果提交到华为等应用市场,会提示Unity开发的游戏在启动时就获取ANROID ID等信息,那么网上的教程指引需要修改UnityConnectSettings.asset,但在mac OS下,打开UnityConnectSettings.asset进行编辑不是件容易事,但其实可以通过代码进行修改。
首先,创建一个继承于EditorWindow的类,用来编写Editor方法。在方法里添加以下代码
AnalyticsSettings.enabled = false; AnalyticsSettings.initializeOnStartup = false; CrashReportingSettings.enabled = false; Analytics.enabled = false; Analytics.deviceStatsEnabled = false; PerformanceReporting.enabled = false; AdvertisementSettings.initializeOnStartup = false;
保存到菜单中点击按钮执行这段代码,就OK了
如果想要打印UnityConnectSettings.asset来看下,可以用以下代码来输出
Object conenctSettingsRes = EditorResources.Load<Object>("ProjectSettings/UnityConnectSettings.asset"); SerializedObject conenctSettingsObj = new SerializedObject(conenctSettingsRes); SerializedProperty iterator = conenctSettingsObj.GetIterator(); var sb = new StringBuilder(); sb.AppendLine("Visible Internal Properties:"); do { string itValue = getValue(iterator); sb.AppendLine($"\t{iterator.name} : {itValue}"); } while (iterator.NextVisible(true)); Debug.Log(sb.ToString());
这样可以在Console中很方便地看到当前UnityConnectSettings.asset的值是怎样了
- 本文固定链接: https://freemanapp.com/zh/?p=922
- 转载请注明: freeman 于 FreemanApp 发表