void NotificationModuleGUI() { EditorGUILayout.BeginVertical(EM_GUIStyleManager.GetCustomStyle("Module Box")); EditorGUI.BeginChangeCheck(); isNotificationModuleEnable.boolValue = EM_EditorGUI.ModuleToggle(isNotificationModuleEnable.boolValue, NotificationModuleLabel); if (EditorGUI.EndChangeCheck()) { // Update the main prefab according to the toggle state. GameObject prefab = EM_EditorUtil.GetMainPrefab(); if (!isNotificationModuleEnable.boolValue) { EM_Manager.DisableNotificationModule(prefab); } else { EM_Manager.EnableNotificationModule(prefab); } } // Now draw the GUI. if (!isNotificationModuleEnable.boolValue) { EditorGUILayout.Space(); EditorGUILayout.HelpBox(NotificationModuleIntro, MessageType.Info); } else { #if !EM_ONESIGNAL EditorGUILayout.Space(); EditorGUILayout.HelpBox(OneSignalImportInstruction, MessageType.Error); EditorGUILayout.Space(); if (GUILayout.Button("Download OneSignal Plugin", GUILayout.Height(EM_GUIStyleManager.buttonHeight))) { EM_ExternalPluginManager.DownloadOneSignalPlugin(); } #else EditorGUILayout.Space(); EditorGUILayout.HelpBox(OneSignalAvailMsg, MessageType.Info); EditorGUILayout.Space(); if (GUILayout.Button("Download OneSignal Plugin", GUILayout.Height(EM_GUIStyleManager.buttonHeight))) { EM_ExternalPluginManager.DownloadOneSignalPlugin(); } // OneSignal setup EditorGUILayout.Space(); EditorGUILayout.LabelField("ONESIGNAL SETUP", EditorStyles.boldLabel); NotificationProperties.oneSignalAppId.property.stringValue = EditorGUILayout.TextField(NotificationProperties.oneSignalAppId.content, NotificationProperties.oneSignalAppId.property.stringValue); // Auto-init setup EditorGUILayout.Space(); EditorGUILayout.LabelField("AUTO-INIT CONFIG", EditorStyles.boldLabel); NotificationProperties.autoInit.property.boolValue = EditorGUILayout.Toggle(NotificationProperties.autoInit.content, NotificationProperties.autoInit.property.boolValue); // Auto init delay EditorGUI.BeginDisabledGroup(!NotificationProperties.autoInit.property.boolValue); NotificationProperties.autoInitDelay.property.floatValue = EditorGUILayout.FloatField(NotificationProperties.autoInitDelay.content, NotificationProperties.autoInitDelay.property.floatValue); EditorGUI.EndDisabledGroup(); // Init tip if (!NotificationProperties.autoInit.property.boolValue) { EditorGUILayout.Space(); EditorGUILayout.HelpBox(NotificationManualInitInstruction, MessageType.Info); } #endif } EditorGUILayout.EndVertical(); }
void IAPModuleGUI() { EditorGUILayout.BeginVertical(EM_GUIStyleManager.GetCustomStyle("Module Box")); EditorGUI.BeginChangeCheck(); isIAPModuleEnable.boolValue = EM_EditorGUI.ModuleToggle(isIAPModuleEnable.boolValue, IAPModuleLabel); if (EditorGUI.EndChangeCheck()) { GameObject prefab = EM_EditorUtil.GetMainPrefab(); if (!isIAPModuleEnable.boolValue) { EM_Manager.DisableIAPModule(prefab); } else { EM_Manager.EnableIAPModule(prefab); } } // Now draw the GUI. if (!isIAPModuleEnable.boolValue) { EditorGUILayout.Space(); EditorGUILayout.HelpBox(IAPModuleIntro, MessageType.Info); } else { #if !EM_UIAP EditorGUILayout.Space(); EditorGUILayout.HelpBox(UnityIAPEnableInstruction, MessageType.Error); #else // Select target Android store, like using the Window > Unity IAP > Android > Target ... menu item. EditorGUILayout.Space(); EditorGUILayout.LabelField("[ANDROID] TARGET STORE", EditorStyles.boldLabel); EditorGUI.BeginChangeCheck(); IAPProperties.targetAndroidStore.property.enumValueIndex = EditorGUILayout.Popup( IAPProperties.targetAndroidStore.content.text, IAPProperties.targetAndroidStore.property.enumValueIndex, IAPProperties.targetAndroidStore.property.enumDisplayNames ); if (EditorGUI.EndChangeCheck()) { SetTargetAndroidStore((IAPAndroidStore)IAPProperties.targetAndroidStore.property.enumValueIndex); } // Receipt validation EditorGUILayout.Space(); EditorGUILayout.LabelField("RECEIPT VALIDATION", EditorStyles.boldLabel); EditorGUILayout.HelpBox("Unity IAP offers local receipt validation for extra security. Apple stores and Google Play store only.", MessageType.None); // iOS store. EditorGUI.BeginDisabledGroup(!isAppleTangleValid); IAPProperties.validateAppleReceipt.property.boolValue = EditorGUILayout.Toggle(IAPProperties.validateAppleReceipt.content, IAPProperties.validateAppleReceipt.property.boolValue); EditorGUI.EndDisabledGroup(); // Always disable the option if AppleTangle is not valid. if (!isAppleTangleValid) { IAPProperties.validateAppleReceipt.property.boolValue = false; } // Google Play store. bool isTargetingGooglePlay = IAPProperties.targetAndroidStore.property.enumValueIndex == (int)IAPAndroidStore.GooglePlay; EditorGUI.BeginDisabledGroup(!isGooglePlayTangleValid); IAPProperties.validateGooglePlayReceipt.property.boolValue = EditorGUILayout.Toggle(IAPProperties.validateGooglePlayReceipt.content, IAPProperties.validateGooglePlayReceipt.property.boolValue); EditorGUI.EndDisabledGroup(); // Always disable the option if GooglePlayTangle is not valid. if (!isGooglePlayTangleValid) { IAPProperties.validateGooglePlayReceipt.property.boolValue = false; } if (!isAppleTangleValid || (!isGooglePlayTangleValid && isTargetingGooglePlay)) { string rvMsg = "Please go to Window > Unity IAP > IAP Receipt Validation Obfuscator and create obfuscated secrets to enable receipt validation for Apple stores and Google Play store."; if (!isAppleTangleValid) { rvMsg += " Note that you don't need to provide a Google Play public key if you're only targeting Apple stores."; } else { rvMsg = rvMsg.Replace("Apple stores and ", ""); } if (isGooglePlayTangleValid || !isTargetingGooglePlay) { rvMsg = rvMsg.Replace(" and Google Play store", ""); } EditorGUILayout.HelpBox(rvMsg, MessageType.Warning); } // Product list EditorGUILayout.Space(); EditorGUILayout.LabelField("PRODUCTS", EditorStyles.boldLabel); EMProperty products = IAPProperties.products; if (products.property.arraySize > 0) { EditorGUI.indentLevel++; isIAPProductsFoldout = EditorGUILayout.Foldout(isIAPProductsFoldout, products.property.arraySize + " " + products.content.text); EditorGUI.indentLevel--; if (isIAPProductsFoldout) { // Index of the element on which buttons are clicked. int deleteIndex = -1; int moveUpIndex = -1; int moveDownIndex = -1; for (int i = 0; i < products.property.arraySize; i++) { SerializedProperty element = products.property.GetArrayElementAtIndex(i); bool isDeleted = false; bool isMovedUp = false; bool isMovedDown = false; EditorGUILayout.Space(); DrawIAPProduct( element, ref isDeleted, ref isMovedUp, ref isMovedDown, i > 0, i < products.property.arraySize - 1 ); if (isDeleted) { deleteIndex = i; } if (isMovedUp) { moveUpIndex = i; } if (isMovedDown) { moveDownIndex = i; } } // Delete. if (deleteIndex >= 0) { products.property.DeleteArrayElementAtIndex(deleteIndex); } // Move up. if (moveUpIndex > 0) { products.property.MoveArrayElement(moveUpIndex, moveUpIndex - 1); } // Move down. if (moveDownIndex >= 0 && moveDownIndex < products.property.arraySize - 1) { products.property.MoveArrayElement(moveDownIndex, moveDownIndex + 1); } // Detect duplicate product names. string duplicateName = EM_EditorUtil.FindDuplicateNameInArrayProperty(products.property, IAPProduct_NameProperty); if (!string.IsNullOrEmpty(duplicateName)) { EditorGUILayout.Space(); EditorGUILayout.HelpBox("Found duplicate name of \"" + duplicateName + "\".", MessageType.Warning); } } } else { EditorGUILayout.HelpBox("No products added.", MessageType.None); } EditorGUILayout.Space(); if (GUILayout.Button("Add New Product", GUILayout.Height(EM_GUIStyleManager.buttonHeight))) { // Add new IAP product. AddNewProduct(products.property); // Open the foldout if it's closed. isIAPProductsFoldout = true; } // Constant generation. EditorGUILayout.Space(); EditorGUILayout.LabelField("CONSTANTS CLASS GENERATION", EditorStyles.boldLabel); EditorGUILayout.HelpBox(IAPConstantGenerationIntro, MessageType.None); EditorGUILayout.Space(); if (GUILayout.Button("Generate Constants Class", GUILayout.Height(EM_GUIStyleManager.buttonHeight))) { GenerateIAPConstants(); } #endif } EditorGUILayout.EndVertical(); }
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 GameServiceModuleGUI() { EditorGUILayout.BeginVertical(EM_GUIStyleManager.GetCustomStyle("Module Box")); EditorGUI.BeginChangeCheck(); isGameServiceModuleEnable.boolValue = EM_EditorGUI.ModuleToggle(isGameServiceModuleEnable.boolValue, GameServiceModuleLabel); // Update the main prefab according to the toggle state. if (EditorGUI.EndChangeCheck()) { GameObject prefab = EM_EditorUtil.GetMainPrefab(); if (!isGameServiceModuleEnable.boolValue) { EM_Manager.DisableGameServiceModule(prefab); } else { EM_Manager.EnableGameServiceModule(prefab); } } // Now draw the GUI. if (!isGameServiceModuleEnable.boolValue) { EditorGUILayout.Space(); EditorGUILayout.HelpBox(GameServiceModuleIntro, MessageType.Info); } else { #if UNITY_ANDROID && !EM_GPGS EditorGUILayout.Space(); EditorGUILayout.HelpBox(AndroidGPGSImportInstruction, MessageType.Error); EditorGUILayout.Space(); if (GUILayout.Button("Download Google Play Games Plugin", GUILayout.Height(EM_GUIStyleManager.buttonHeight))) { EM_ExternalPluginManager.DownloadGooglePlayGamesPlugin(); } #elif UNITY_ANDROID && EM_GPGS EditorGUILayout.Space(); EditorGUILayout.HelpBox(AndroidGPGSAvailMsg, MessageType.Info); EditorGUILayout.Space(); if (GUILayout.Button("Download Google Play Games Plugin", GUILayout.Height(EM_GUIStyleManager.buttonHeight))) { EM_ExternalPluginManager.DownloadGooglePlayGamesPlugin(); } // Android Google Play Games setup EditorGUILayout.Space(); EditorGUILayout.LabelField("[ANDROID] GOOGLE PLAY GAMES SETUP", EditorStyles.boldLabel); // GPGPS debug log GameServiceProperties.gpgsDebugLog.property.boolValue = EditorGUILayout.Toggle(GameServiceProperties.gpgsDebugLog.content, GameServiceProperties.gpgsDebugLog.property.boolValue); // Text area to input the Android resource. EditorGUILayout.Space(); EditorGUILayout.HelpBox(AndroidGPGPSSetupInstruction, MessageType.None); EditorGUILayout.LabelField(GameServiceProperties.androidXmlResources.content, EditorStyles.boldLabel); // Draw text area inside a scroll view. androidResourcesTextAreaScroll = GUILayout.BeginScrollView(androidResourcesTextAreaScroll, false, false, GUILayout.Height(EditorGUIUtility.singleLineHeight * 10)); GameServiceProperties.androidXmlResources.property.stringValue = EditorGUILayout.TextArea( GameServiceProperties.androidXmlResources.property.stringValue, GUILayout.Height(EditorGUIUtility.singleLineHeight * 100), GUILayout.ExpandHeight(true)); EditorGUILayout.EndScrollView(); EditorGUILayout.Space(); // Replicate the "Setup" button within the Android GPGS setup window. if (GUILayout.Button("Setup Google Play Games", GUILayout.Height(EM_GUIStyleManager.buttonHeight))) { string webClientId = null; // Web ClientId, not required for Games Services. string folder = EM_Constants.GeneratedFolder; // Folder to contain the generated id constant class. string className = EM_Constants.AndroidGPGSConstantClassName; // Name of the generated id constant class. string resourceXmlData = GameServiceProperties.androidXmlResources.property.stringValue; // The xml resources inputted. string nearbySvcId = null; // Nearby Connection Id, not supported by us. bool requiresGooglePlus = false; // Not required Google+ API. try { if (GPGSUtil.LooksLikeValidPackageName(className)) { SetupAndroidGPGS(webClientId, folder, className, resourceXmlData, nearbySvcId, requiresGooglePlus); } } catch (System.Exception e) { GPGSUtil.Alert( GPGSStrings.Error, "Invalid classname: " + e.Message); } } #endif #if !UNITY_ANDROID || (UNITY_ANDROID && EM_GPGS) // Auto-init config EditorGUILayout.Space(); EditorGUILayout.LabelField("AUTO-INIT CONFIG", EditorStyles.boldLabel); GameServiceProperties.autoInit.property.boolValue = EditorGUILayout.Toggle(GameServiceProperties.autoInit.content, GameServiceProperties.autoInit.property.boolValue); EditorGUI.BeginDisabledGroup(!GameServiceProperties.autoInit.property.boolValue); GameServiceProperties.autoInitDelay.property.floatValue = EditorGUILayout.FloatField(GameServiceProperties.autoInitDelay.content, GameServiceProperties.autoInitDelay.property.floatValue); EditorGUI.EndDisabledGroup(); GameServiceProperties.androidMaxLoginRequest.property.intValue = EditorGUILayout.IntField(GameServiceProperties.androidMaxLoginRequest.content, GameServiceProperties.androidMaxLoginRequest.property.intValue); if (!GameServiceProperties.autoInit.property.boolValue) { EditorGUILayout.Space(); EditorGUILayout.HelpBox(GameServiceManualInitInstruction, MessageType.Info); } // Leaderboard setup. EditorGUILayout.Space(); EditorGUILayout.LabelField("LEADERBOARD SETUP", EditorStyles.boldLabel); DrawGameServiceItemArray("Leaderboard", GameServiceProperties.leaderboards, ref isLeadeboardsFoldout); // Achievement setup. EditorGUILayout.Space(); EditorGUILayout.LabelField("ACHIEVEMENT SETUP", EditorStyles.boldLabel); DrawGameServiceItemArray("Achievement", GameServiceProperties.achievements, ref isAchievementsFoldout); // Constant generation. EditorGUILayout.Space(); EditorGUILayout.LabelField("CONSTANTS CLASS GENERATION", EditorStyles.boldLabel); EditorGUILayout.HelpBox(GameServiceConstantGenerationIntro, MessageType.None); EditorGUILayout.Space(); if (GUILayout.Button("Generate Constants Class", GUILayout.Height(EM_GUIStyleManager.buttonHeight))) { GenerateGameServiceConstants(); } #endif } EditorGUILayout.EndVertical(); }