Nenhuma descrição
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

GoogleMobileAdsSettingsEditor.cs 5.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. using UnityEditor;
  2. using UnityEngine;
  3. namespace GoogleMobileAds.Editor
  4. {
  5. [InitializeOnLoad]
  6. [CustomEditor(typeof(GoogleMobileAdsSettings))]
  7. public class GoogleMobileAdsSettingsEditor : UnityEditor.Editor
  8. {
  9. SerializedProperty _appIdAndroid;
  10. SerializedProperty _appIdiOS;
  11. SerializedProperty _enableKotlinXCoroutinesPackagingOption;
  12. SerializedProperty _optimizeInitialization;
  13. SerializedProperty _optimizeAdLoading;
  14. SerializedProperty _userTrackingUsageDescription;
  15. SerializedProperty _validateGradleDependencies;
  16. [MenuItem("Assets/Google Mobile Ads/Settings...")]
  17. public static void OpenInspector()
  18. {
  19. Selection.activeObject = GoogleMobileAdsSettings.LoadInstance();
  20. }
  21. public void OnEnable()
  22. {
  23. _appIdAndroid = serializedObject.FindProperty("adMobAndroidAppId");
  24. _appIdiOS = serializedObject.FindProperty("adMobIOSAppId");
  25. _enableKotlinXCoroutinesPackagingOption =
  26. serializedObject.FindProperty("enableKotlinXCoroutinesPackagingOption");
  27. _optimizeInitialization = serializedObject.FindProperty("optimizeInitialization");
  28. _optimizeAdLoading = serializedObject.FindProperty("optimizeAdLoading");
  29. _userTrackingUsageDescription =
  30. serializedObject.FindProperty("userTrackingUsageDescription");
  31. _validateGradleDependencies =
  32. serializedObject.FindProperty("validateGradleDependencies");
  33. }
  34. public override void OnInspectorGUI()
  35. {
  36. // Make sure the Settings object has all recent changes.
  37. serializedObject.Update();
  38. var settings = (GoogleMobileAdsSettings)target;
  39. if(settings == null)
  40. {
  41. UnityEngine.Debug.LogError("GoogleMobileAdsSettings is null.");
  42. return;
  43. }
  44. EditorGUIUtility.labelWidth = 60.0f;
  45. EditorGUILayout.LabelField("Google Mobile Ads App ID", EditorStyles.boldLabel);
  46. EditorGUI.indentLevel++;
  47. EditorGUILayout.PropertyField(_appIdAndroid, new GUIContent("Android"));
  48. EditorGUILayout.PropertyField(_appIdiOS, new GUIContent("iOS"));
  49. EditorGUILayout.HelpBox(
  50. "Google Mobile Ads App ID will look similar to this sample ID: ca-app-pub-3940256099942544~3347511713",
  51. MessageType.Info);
  52. EditorGUI.indentLevel--;
  53. EditorGUILayout.Separator();
  54. EditorGUIUtility.labelWidth = 325.0f;
  55. EditorGUILayout.LabelField("Android settings", EditorStyles.boldLabel);
  56. EditorGUI.indentLevel++;
  57. EditorGUI.BeginChangeCheck();
  58. EditorGUILayout.PropertyField(_enableKotlinXCoroutinesPackagingOption,
  59. new GUIContent("Enable kotlinx.coroutines packaging option."));
  60. if (settings.EnableKotlinXCoroutinesPackagingOption)
  61. {
  62. EditorGUILayout.HelpBox(
  63. "Adds instruction to fix a build.gradle build error with message"+
  64. " '2 files found with path 'META-INF/kotlinx_coroutines_core.version'."+
  65. " For more details see https://developers.google.com/admob/unity/gradle",
  66. MessageType.Info);
  67. }
  68. EditorGUILayout.PropertyField(_validateGradleDependencies,
  69. new GUIContent("Remove property tag from GMA Android SDK"));
  70. if (settings.ValidateGradleDependencies)
  71. {
  72. EditorGUILayout.HelpBox(
  73. "This option ensures the GMA Android SDK is compatible with the version of " +
  74. "Android Gradle Plugin being used. Enabling this option is required for Unity" +
  75. " Projects that use Android Gradle Plugin under version 4.2.2.",
  76. MessageType.Info);
  77. }
  78. EditorGUILayout.PropertyField(_optimizeInitialization,
  79. new GUIContent("Optimize initialization"));
  80. if (settings.OptimizeInitialization) {
  81. EditorGUILayout.HelpBox(
  82. "Initialization will be offloaded to a background thread.",
  83. MessageType.Info);
  84. }
  85. EditorGUILayout.PropertyField(_optimizeAdLoading,
  86. new GUIContent("Optimize ad loading"));
  87. if (settings.OptimizeAdLoading) {
  88. EditorGUILayout.HelpBox(
  89. "Ad loading tasks will be offloaded to a background thread.",
  90. MessageType.Info);
  91. }
  92. EditorGUI.indentLevel--;
  93. EditorGUILayout.Separator();
  94. EditorGUIUtility.labelWidth = 205.0f;
  95. EditorGUILayout.LabelField("UMP-specific settings", EditorStyles.boldLabel);
  96. EditorGUI.indentLevel++;
  97. EditorGUILayout.PropertyField(_userTrackingUsageDescription,
  98. new GUIContent("User Tracking Usage Description"));
  99. EditorGUILayout.HelpBox(
  100. "A message that informs the user why an iOS app is requesting permission to " +
  101. "use data for tracking the user or the device.", MessageType.Info);
  102. EditorGUI.indentLevel--;
  103. EditorGUILayout.Separator();
  104. serializedObject.ApplyModifiedProperties();
  105. }
  106. }
  107. }