Bez popisu
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

GoogleMobileAdsSettingsEditor.cs 6.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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 _delayAppMeasurement;
  12. SerializedProperty _enableKotlinXCoroutinesPackagingOption;
  13. SerializedProperty _optimizeInitialization;
  14. SerializedProperty _optimizeAdLoading;
  15. SerializedProperty _userTrackingUsageDescription;
  16. SerializedProperty _validateGradleDependencies;
  17. [MenuItem("Assets/Google Mobile Ads/Settings...")]
  18. public static void OpenInspector()
  19. {
  20. Selection.activeObject = GoogleMobileAdsSettings.LoadInstance();
  21. }
  22. public void OnEnable()
  23. {
  24. _appIdAndroid = serializedObject.FindProperty("adMobAndroidAppId");
  25. _appIdiOS = serializedObject.FindProperty("adMobIOSAppId");
  26. _delayAppMeasurement = serializedObject.FindProperty("delayAppMeasurementInit");
  27. _enableKotlinXCoroutinesPackagingOption =
  28. serializedObject.FindProperty("enableKotlinXCoroutinesPackagingOption");
  29. _optimizeInitialization = serializedObject.FindProperty("optimizeInitialization");
  30. _optimizeAdLoading = serializedObject.FindProperty("optimizeAdLoading");
  31. _userTrackingUsageDescription =
  32. serializedObject.FindProperty("userTrackingUsageDescription");
  33. _validateGradleDependencies =
  34. serializedObject.FindProperty("validateGradleDependencies");
  35. }
  36. public override void OnInspectorGUI()
  37. {
  38. // Make sure the Settings object has all recent changes.
  39. serializedObject.Update();
  40. var settings = (GoogleMobileAdsSettings)target;
  41. if(settings == null)
  42. {
  43. UnityEngine.Debug.LogError("GoogleMobileAdsSettings is null.");
  44. return;
  45. }
  46. EditorGUILayout.LabelField("Google Mobile Ads App ID", EditorStyles.boldLabel);
  47. EditorGUI.indentLevel++;
  48. EditorGUILayout.PropertyField(_appIdAndroid, new GUIContent("Android"));
  49. EditorGUILayout.PropertyField(_appIdiOS, new GUIContent("iOS"));
  50. EditorGUILayout.HelpBox(
  51. "Google Mobile Ads App ID will look similar to this sample ID: ca-app-pub-3940256099942544~3347511713",
  52. MessageType.Info);
  53. EditorGUI.indentLevel--;
  54. EditorGUILayout.Separator();
  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. EditorGUILayout.LabelField("AdMob-specific settings", EditorStyles.boldLabel);
  95. EditorGUI.indentLevel++;
  96. EditorGUI.BeginChangeCheck();
  97. EditorGUILayout.PropertyField(_delayAppMeasurement,
  98. new GUIContent("Delay app measurement"));
  99. if (settings.DelayAppMeasurementInit) {
  100. EditorGUILayout.HelpBox(
  101. "Delays app measurement until you explicitly initialize the Mobile Ads SDK or load an ad.",
  102. MessageType.Info);
  103. }
  104. EditorGUI.indentLevel--;
  105. EditorGUILayout.Separator();
  106. EditorGUILayout.LabelField("UMP-specific settings", EditorStyles.boldLabel);
  107. EditorGUI.indentLevel++;
  108. EditorGUILayout.PropertyField(_userTrackingUsageDescription,
  109. new GUIContent("User Tracking Usage Description"));
  110. EditorGUILayout.HelpBox(
  111. "A message that informs the user why an iOS app is requesting permission to " +
  112. "use data for tracking the user or the device.", MessageType.Info);
  113. EditorGUI.indentLevel--;
  114. EditorGUILayout.Separator();
  115. serializedObject.ApplyModifiedProperties();
  116. }
  117. }
  118. }