void AdModuleGUI() { EditorGUILayout.BeginVertical(EM_GUIStyleManager.GetCustomStyle("Module Box")); EditorGUI.BeginChangeCheck(); isAdModuleEnable.boolValue = EM_EditorGUI.ModuleToggle(isAdModuleEnable.boolValue, AdModuleLabel); if (EditorGUI.EndChangeCheck()) { GameObject prefab = EM_EditorUtil.GetMainPrefab(); if (!isAdModuleEnable.boolValue) { EM_Manager.DisableAdModule(prefab); } else { EM_Manager.EnableAdModule(prefab); } } // Now draw the GUI. if (!isAdModuleEnable.boolValue) { EditorGUILayout.Space(); EditorGUILayout.HelpBox(AdModuleIntro, MessageType.Info); } else { // AdMob setup EditorGUILayout.Space(); EditorGUILayout.LabelField("ADMOB SETUP", EditorStyles.boldLabel); #if !EM_ADMOB EditorGUILayout.HelpBox(AdMobImportInstruction, MessageType.Warning); EditorGUILayout.Space(); if (GUILayout.Button("Download Google Mobile Ads Plugin", GUILayout.Height(EM_GUIStyleManager.buttonHeight))) { EM_ExternalPluginManager.DownloadGoogleMobileAdsPlugin(); } #else EditorGUILayout.HelpBox(AdMobAvailMsg, MessageType.Info); EditorGUILayout.Space(); if (GUILayout.Button("Download Google Mobile Ads Plugin", GUILayout.Height(EM_GUIStyleManager.buttonHeight))) { EM_ExternalPluginManager.DownloadGoogleMobileAdsPlugin(); } EditorGUILayout.Space(); EditorGUI.indentLevel++; EditorGUILayout.PropertyField(AdProperties.iosAdMobConfig.property, AdProperties.iosAdMobConfig.content, true); EditorGUILayout.PropertyField(AdProperties.androidAdMobConfig.property, AdProperties.androidAdMobConfig.content, true); EditorGUI.indentLevel--; #endif // Chartboost setup EditorGUILayout.Space(); EditorGUILayout.LabelField("CHARTBOOST SETUP", EditorStyles.boldLabel); #if !EM_CHARTBOOST EditorGUILayout.HelpBox(ChartboostImportInstruction, MessageType.Warning); EditorGUILayout.Space(); if (GUILayout.Button("Download Chartboost Plugin", GUILayout.Height(EM_GUIStyleManager.buttonHeight))) { EM_ExternalPluginManager.DownloadChartboostPlugin(); } #else EditorGUILayout.HelpBox(ChartboostAvailMsg, MessageType.Info); EditorGUILayout.Space(); if (GUILayout.Button("Download Chartboost Plugin", GUILayout.Height(EM_GUIStyleManager.buttonHeight))) { EM_ExternalPluginManager.DownloadChartboostPlugin(); } if (GUILayout.Button("Setup Chartboost", GUILayout.Height(EM_GUIStyleManager.buttonHeight))) { // Open Chartboost settings window. ChartboostSDK.CBSettings.Edit(); } #endif // Heyzap setup EditorGUILayout.Space(); EditorGUILayout.LabelField("HEYZAP SETUP", EditorStyles.boldLabel); #if !EM_HEYZAP EditorGUILayout.HelpBox(HeyzapImportInstruction, MessageType.Warning); EditorGUILayout.Space(); if (GUILayout.Button("Download Heyzap Plugin", GUILayout.Height(EM_GUIStyleManager.buttonHeight))) { EM_ExternalPluginManager.DownloadHeyzapPlugin(); } #else EditorGUILayout.HelpBox(HeyzapAvailMsg, MessageType.Info); EditorGUILayout.Space(); if (GUILayout.Button("Download Heyzap Plugin", GUILayout.Height(EM_GUIStyleManager.buttonHeight))) { EM_ExternalPluginManager.DownloadHeyzapPlugin(); } EditorGUILayout.Space(); AdProperties.heyzapPublisherId.property.stringValue = EditorGUILayout.TextField(AdProperties.heyzapPublisherId.content, AdProperties.heyzapPublisherId.property.stringValue); AdProperties.heyzapShowTestSuite.property.boolValue = EditorGUILayout.Toggle(AdProperties.heyzapShowTestSuite.content, AdProperties.heyzapShowTestSuite.property.boolValue); #endif // UnityAds setup EditorGUILayout.Space(); EditorGUILayout.LabelField("UNITY ADS SETUP", EditorStyles.boldLabel); #if !UNITY_ADS EditorGUILayout.HelpBox(UnityAdsUnvailableWarning, MessageType.Warning); #else EditorGUILayout.HelpBox(UnityAdsAvailableMsg, MessageType.Info); #endif // Ads auto-load setup EditorGUILayout.Space(); EditorGUILayout.LabelField("AUTO AD-LOADING CONFIG", EditorStyles.boldLabel); AdProperties.autoLoadDefaultAds.property.boolValue = EditorGUILayout.Toggle(AdProperties.autoLoadDefaultAds.content, AdProperties.autoLoadDefaultAds.property.boolValue); AdProperties.adCheckingInterval.property.floatValue = EditorGUILayout.FloatField(AdProperties.adCheckingInterval.content, AdProperties.adCheckingInterval.property.floatValue); AdProperties.adLoadingInterval.property.floatValue = EditorGUILayout.FloatField(AdProperties.adLoadingInterval.content, AdProperties.adLoadingInterval.property.floatValue); EditorGUILayout.Space(); EditorGUILayout.LabelField("DEFAULT AD NETWORKS", EditorStyles.boldLabel); EditorGUI.indentLevel++; EditorGUILayout.PropertyField(AdProperties.iosDefaultAdNetworks.property, AdProperties.iosDefaultAdNetworks.content, true); EditorGUILayout.PropertyField(AdProperties.androidDefaultAdNetworks.property, AdProperties.androidDefaultAdNetworks.content, true); EditorGUI.indentLevel--; // Now check if there's any default ad network that doesn't have plugin imported and show warnings. AdSettings.DefaultAdNetworks iosDefault = EM_Settings.Advertising.IosDefaultAdNetworks; AdSettings.DefaultAdNetworks androidDefault = EM_Settings.Advertising.AndroidDefaultAdNetworks; List <AdNetwork> usedNetworks = new List <AdNetwork>(); AddWithoutRepeat(usedNetworks, (AdNetwork)iosDefault.bannerAdNetwork); AddWithoutRepeat(usedNetworks, (AdNetwork)iosDefault.interstitialAdNetwork); AddWithoutRepeat(usedNetworks, (AdNetwork)iosDefault.rewardedAdNetwork); AddWithoutRepeat(usedNetworks, (AdNetwork)androidDefault.bannerAdNetwork); AddWithoutRepeat(usedNetworks, (AdNetwork)androidDefault.interstitialAdNetwork); AddWithoutRepeat(usedNetworks, (AdNetwork)androidDefault.rewardedAdNetwork); bool addedSpace = false; foreach (AdNetwork network in usedNetworks) { if (!IsPluginAvail(network)) { if (!addedSpace) { EditorGUILayout.Space(); addedSpace = true; } EditorGUILayout.HelpBox("Default ad network " + network.ToString() + " has no SDK. Please import its plugin.", MessageType.Warning); } } } EditorGUILayout.EndVertical(); }
void DrawAdMobSettings() { EditorGUILayout.Space(); DrawUppercaseSection("ADMOB_SETUP_FOLDOUT_KEY", "ADMOB", () => { #if !EM_ADMOB EditorGUILayout.HelpBox(AdMobImportInstruction, MessageType.Warning); if (GUILayout.Button("Download Google Mobile Ads Plugin", GUILayout.Height(EM_GUIStyleManager.buttonHeight))) { EM_ExternalPluginManager.DownloadGoogleMobileAdsPlugin(); } #else EditorGUILayout.HelpBox(AdMobAvailMsg, MessageType.Info); if (GUILayout.Button("Download Google Mobile Ads Plugin", GUILayout.Height(EM_GUIStyleManager.buttonHeight))) { EM_ExternalPluginManager.DownloadGoogleMobileAdsPlugin(); } // App ID. EditorGUILayout.Space(); EditorGUILayout.LabelField("App ID", EditorStyles.boldLabel); EditorGUI.indentLevel++; EditorGUILayout.PropertyField(AdProperties.admobAppId.property, AdProperties.admobAppId.content, true); EditorGUI.indentLevel--; // Default placements. EditorGUILayout.Space(); EditorGUILayout.LabelField("Default Placement", EditorStyles.boldLabel); EditorGUI.indentLevel++; EditorGUILayout.PropertyField(AdProperties.admobDefaultBannerAdId.property, AdProperties.admobDefaultBannerAdId.content, true); EditorGUILayout.PropertyField(AdProperties.admobDefaultInterstitialAdId.property, AdProperties.admobDefaultInterstitialAdId.content, true); EditorGUILayout.PropertyField(AdProperties.admobDefaultRewardedAdId.property, AdProperties.admobDefaultRewardedAdId.content, true); EditorGUI.indentLevel--; // Custom placements. EditorGUILayout.Space(); EditorGUILayout.LabelField("Custom Placements", EditorStyles.boldLabel); EditorGUI.indentLevel++; EditorGUILayout.PropertyField(AdProperties.admobCustomBannerAdIds.property, AdProperties.admobCustomBannerAdIds.content, true); EditorGUILayout.PropertyField(AdProperties.admobCustomInterstitialAdIds.property, AdProperties.admobCustomInterstitialAdIds.content, true); EditorGUILayout.PropertyField(AdProperties.admobCustomRewardedAdIds.property, AdProperties.admobCustomRewardedAdIds.content, true); EditorGUI.indentLevel--; // Ad targeting settings. EditorGUILayout.Space(); var childDirected = AdProperties.admobTargetingSettings.property.FindPropertyRelative("mTagForChildDirectedTreatment"); var extras = AdProperties.admobTargetingSettings.property.FindPropertyRelative("mExtraOptions"); EditorGUILayout.LabelField(AdProperties.admobTargetingSettings.content, EditorStyles.boldLabel); EditorGUILayout.PropertyField(childDirected, new GUIContent("Tag For Child Directed Treatment")); EditorGUI.indentLevel++; EditorGUILayout.PropertyField(extras, new GUIContent("Extra Options")); EditorGUI.indentLevel--; // Test mode. EditorGUILayout.Space(); EditorGUILayout.LabelField("Test Mode", EditorStyles.boldLabel); EditorGUILayout.PropertyField(AdProperties.admobEnableTestMode.property, AdProperties.admobEnableTestMode.content); if (AdProperties.admobEnableTestMode.property.boolValue) { DrawPropertyAsResizableArray(AdProperties.admobTestDeviceIds.property, "Test Device IDs"); DrawAllElementsInArrayProperty(AdProperties.admobTestDeviceIds.property); } else { // Clear test device IDs when test mode is disable for safety. AdProperties.admobTestDeviceIds.property.ClearArray(); } #endif }); }