Example #1
0
        void UtilityModuleGUI()
        {
            EditorGUILayout.BeginVertical(EM_GUIStyleManager.GetCustomStyle("Module Box"));

            EM_EditorGUI.ModuleLabel(UtilityModuleLabel);

            // Rating Request settings
            EditorGUILayout.Space();
            EditorGUILayout.LabelField("[STORE REVIEW] REQUEST DIALOG CONFIG", EditorStyles.boldLabel);

            // Appearance
            EditorGUILayout.LabelField("Appearance", EditorStyles.boldLabel);
            EditorGUILayout.HelpBox("All instances of " + RatingDialogContent.PRODUCT_NAME_PLACEHOLDER + " in titles and messages will be replaced by the actual Product Name given in PlayerSettings.", MessageType.Info);
            EditorGUI.indentLevel++;
            EditorGUILayout.PropertyField(RatingRequestProperties.defaultRatingDialogContent.property, RatingRequestProperties.defaultRatingDialogContent.content, true);
            EditorGUI.indentLevel--;

            // Behaviour
            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Behaviour", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(RatingRequestProperties.minimumAcceptedStars.property, RatingRequestProperties.minimumAcceptedStars.content);
            EditorGUILayout.PropertyField(RatingRequestProperties.supportEmail.property, RatingRequestProperties.supportEmail.content);
            EditorGUILayout.PropertyField(RatingRequestProperties.iosAppId.property, RatingRequestProperties.iosAppId.content);

            // Display constraints
            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Display Constraints", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(RatingRequestProperties.annualCap.property, RatingRequestProperties.annualCap.content);
            EditorGUILayout.PropertyField(RatingRequestProperties.delayAfterInstallation.property, RatingRequestProperties.delayAfterInstallation.content);
            EditorGUILayout.PropertyField(RatingRequestProperties.coolingOffPeriod.property, RatingRequestProperties.coolingOffPeriod.content);
            EditorGUILayout.PropertyField(RatingRequestProperties.ignoreConstraintsInDevelopment.property, RatingRequestProperties.ignoreConstraintsInDevelopment.content);

            EditorGUILayout.EndVertical();
        }
Example #2
0
        public override void OnInspectorGUI()
        {
            // Update the serializedProperty - always do this in the beginning of OnInspectorGUI.
            serializedObject.Update();

            // Draw the module-select toolbar.
            EditorGUILayout.BeginHorizontal();
            EM_EditorGUI.ToolbarButton(new GUIContent(null, EM_GUIStyleManager.NotificationIcon, "Notification"), Module.Notification, ref activeModule, EditorGUIUtility.isProSkin ? EM_GUIStyleManager.ModuleToolbarButtonRight : EM_GUIStyleManager.ModuleToolbarButton);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();

            // Store the toolbar index value to the serialized settings file.
            activeModuleIndex.intValue = (int)activeModule;

            switch (activeModule)
            {
            case Module.Notification:
                NotificationModuleGUI();
                break;
            }

            // Apply changes to the serializedProperty - always do this in the end of OnInspectorGUI.
            serializedObject.ApplyModifiedProperties();
        }
Example #3
0
        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 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();
        }
Example #5
0
        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_PluginManager.DisableIAPModule(prefab);
                }
                else
                {
                    EM_PluginManager.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)
                    {
                        // Draw the array of IAP products.
                        DrawArrayProperty(products.property, DrawIAPProduct);

                        // Detect duplicate product names.
                        string duplicateName = EM_EditorUtil.FindDuplicateFieldInArrayProperty(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 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();
        }
        /// <summary>
        /// Draw the top header of the active module when we open it.
        /// </summary>
        public void DrawModuleSelectBar(Module module, bool clickableBar = true, bool drawBackButton = false)
        {
            /// Get infos of the active module.
            string    name            = GetModuleName(module);
            string    description     = GetModuleDescription(module);
            Texture2D icon            = GetModuleIcon(module);
            var       triggerProperty = GetTriggerProperty(module);
            Action    disableModule   = GetDisableModuleAction(module);
            Action    enableModule    = GetEnableModuleAction(module);

            EditorGUILayout.BeginVertical(ModulePanelStyle, GUILayout.MinHeight(MinModuleBarHeight));
            EditorGUILayout.BeginHorizontal();

            /// Draw back button.
            if (drawBackButton)
            {
                if (GUILayout.Button("", BackButtonStyle))
                {
                    isSelectingModule.boolValue = true;
                }
            }

            /// Draw icon.
            GUILayout.Label(icon, ModuleHeaderIconStyle);

            /// Draw name.
            EditorGUILayout.BeginVertical();
            EditorGUILayout.LabelField(name, ModuleTitleStyle);
            EditorGUILayout.EndVertical();

            /// Draw toggle.
            Rect toggleRect = Rect.zero;

            if (triggerProperty != null)
            {
                EditorGUI.BeginChangeCheck();
                triggerProperty.boolValue = EM_EditorGUI.ModuleToggle(triggerProperty.boolValue, name);
                if (EditorGUI.EndChangeCheck())
                {
                    if (triggerProperty.boolValue)
                    {
                        // Enable the module and also select it.
                        // IMPORTANT: SelectModule() must be done first for the transition to be correct.
                        SelectModule(module);
                        enableModule();
                    }
                    else
                    {
                        // Disable the module and go back to home if is in module settings page.
                        disableModule();
                        isSelectingModule.boolValue = true;
                    }
                }

                toggleRect = GUILayoutUtility.GetLastRect();
            }

            EditorGUILayout.EndHorizontal();

            /// Draw description.
            EditorGUILayout.LabelField(description, ModuleDescriptionStyle);

            EditorGUILayout.EndVertical();

            if (clickableBar)
            {
                /// Draw an invisible button on top of all the elements above
                /// so we can click on it and open the module settings tab.
                /// If there's a toggle the button only extends to its left edge.
                var btnRect = GUILayoutUtility.GetLastRect();
                if (toggleRect != Rect.zero)
                {
                    btnRect.width = toggleRect.x - btnRect.x;
                }

                if (GUI.Button(btnRect, "", GUIStyle.none))
                {
                    if (IsModuleEnable(module))
                    {
                        SelectModule(module);
                    }
                }
            }
        }
        private void DrawUppercaseSection(string key, string sectionName, Action drawer, Action disableModule, Action enableModule, SerializedProperty triggerProperty, Texture2D sectionIcon = null, bool defautFoldout = true)
        {
            if (!uppercaseSectionsFoldoutStates.ContainsKey(key))
            {
                uppercaseSectionsFoldoutStates.Add(key, defautFoldout);
            }

            bool foldout = uppercaseSectionsFoldoutStates[key];

            EditorGUILayout.BeginVertical(EM_GUIStyleManager.GetCustomStyle("Uppercase Section Box"), GUILayout.MinHeight(foldout ? 30 : 0));

            EditorGUILayout.BeginHorizontal(foldout ? EM_GUIStyleManager.UppercaseSectionHeaderExpand : EM_GUIStyleManager.UppercaseSectionHeaderCollapse);

            // Header icon.
            EditorGUILayout.LabelField(new GUIContent(sectionIcon ?? EM_GUIStyleManager.UppercaseSectionHeaderIcon),
                                       EM_GUIStyleManager.GetCustomStyle("Uppercase Section Header Icon"),
                                       GUILayout.Width(DefaultSectionHeaderIconWidth),
                                       GUILayout.Height(DefaultSectionHeaderIconHeight));

            // Header label (and button).
            if (GUILayout.Button(sectionName, EM_GUIStyleManager.GetCustomStyle("Uppercase Section Header Label")))
            {
                uppercaseSectionsFoldoutStates[key] = !uppercaseSectionsFoldoutStates[key];
            }

            // The expand/collapse icon.
            var buttonRect = GUILayoutUtility.GetLastRect();
            var iconRect   = new Rect(buttonRect.x + buttonRect.width - ChevronIconWidth - ChevronIconRightMargin, buttonRect.y, ChevronIconWidth, buttonRect.height);

            GUI.Label(iconRect, GetChevronIcon(foldout), EM_GUIStyleManager.GetCustomStyle("Uppercase Section Header Chevron"));

            /// Draw toggle.
            Rect toggleRect = Rect.zero;

            EditorGUI.BeginChangeCheck();
            if (triggerProperty != null)
            {
                triggerProperty.boolValue = EM_EditorGUI.ModuleToggle(triggerProperty.boolValue, name);
                if (EditorGUI.EndChangeCheck())
                {
                    if (triggerProperty.boolValue)
                    {
                        enableModule();
                    }
                    else
                    {
                        disableModule();
                    }
                }
                toggleRect = GUILayoutUtility.GetLastRect();
            }

            EditorGUILayout.EndHorizontal();

            // Draw the section content.
            if (foldout)
            {
                GUILayout.Space(5);
            }

            if (foldout && drawer != null)
            {
                drawer();
            }

            EditorGUILayout.EndVertical();
        }
Example #8
0
        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_PluginManager.DisableNotificationModule(prefab);
                }
                else
                {
                    EM_PluginManager.EnableNotificationModule(prefab);
                }
            }

            // Now draw the GUI.
            if (!isNotificationModuleEnable.boolValue)
            {
                EditorGUILayout.Space();
                EditorGUILayout.HelpBox(NotificationModuleIntro, MessageType.Info);
            }
            else
            {
                // Initialization 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);
                }

                //--------------------------------------------------------------
                // Uncomment to expose the iOSAuthOptions setting.
                //--------------------------------------------------------------

                /*
                 * // iOS authorization options
                 * EditorGUILayout.PropertyField(NotificationProperties.iosAuthOptions.property, NotificationProperties.iosAuthOptions.content);
                 */

                // Remote notification setup
                EditorGUILayout.Space();
                EditorGUILayout.LabelField("REMOTE NOTIFICATION SETUP", EditorStyles.boldLabel);

                // Push Notification Service
                EditorGUILayout.PropertyField(NotificationProperties.pushNotificationService.property, NotificationProperties.pushNotificationService.content);

                // If using OneSignal...
                if (NotificationProperties.pushNotificationService.property.enumValueIndex == (int)PushNotificationProvider.OneSignal)
                {
                    #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();
                    NotificationProperties.oneSignalAppId.property.stringValue = EditorGUILayout.TextField(NotificationProperties.oneSignalAppId.content, NotificationProperties.oneSignalAppId.property.stringValue);
                    #endif
                }

                // Android Resources Setup
                EditorGUILayout.Space();
                EditorGUILayout.LabelField("ANDROID NOTIFICATION RESOURCES", EditorStyles.boldLabel);
                EditorGUILayout.HelpBox(NotificationAndroidResourcesIntro, MessageType.None);
                EditorGUILayout.Space();

                if (GUILayout.Button("Open Android Notification Icon Generator", GUILayout.Height(EM_GUIStyleManager.buttonHeight)))
                {
                    Application.OpenURL(NotificationAndroidIconGeneratorUrl);
                }

                if (GUILayout.Button("Import Res Folder", GUILayout.Height(EM_GUIStyleManager.buttonHeight)))
                {
                    EditorApplication.delayCall += ImportAndroidNotificationResFolder;
                }

                // Category groups
                EditorGUILayout.Space();
                EditorGUILayout.LabelField("CATEGORY GROUPS", EditorStyles.boldLabel);
                DrawNotificationCategoryGroupsArray(NotificationProperties.categoryGroups, ref notificationIsCategoryGroupsFoldout);

                // Update the list of category group IDs.
                notificationCatGroupIDs = BuildListOfNotificationCategoryGroupIDs();

                // Categories
                EditorGUILayout.Space();
                EditorGUILayout.LabelField("CATEGORIES", EditorStyles.boldLabel);
                EditorGUILayout.HelpBox(NotificationCategoryIntro, MessageType.Info);

                // Draw the default category
                EditorGUILayout.LabelField("Default Category", EditorStyles.boldLabel);
                EditorGUILayout.HelpBox(NotificationDefaultCategoryIntro, MessageType.None);
                DrawNotificationCategory(NotificationProperties.defaultCategory.property);

                if (string.IsNullOrEmpty(EM_Settings.Notifications.DefaultCategory.name) ||
                    string.IsNullOrEmpty(EM_Settings.Notifications.DefaultCategory.id))
                {
                    EditorGUILayout.HelpBox("Default category must have non-empty name and ID.", MessageType.Warning);
                }
                else
                {
                    foreach (var category in EM_Settings.Notifications.UserCategories)
                    {
                        if (!string.IsNullOrEmpty(category.id) && category.id.Equals(EM_Settings.Notifications.DefaultCategory.id))
                        {
                            EditorGUILayout.HelpBox("Default category cannot share the same ID " + category.id + " with another user category.", MessageType.Warning);
                            break;
                        }
                    }
                }

                // Draw user categories
                EditorGUILayout.LabelField("User Categories", EditorStyles.boldLabel);
                DrawNotificationCategoriesArray(NotificationProperties.userCategories, ref notificationIsUserCategoriesFoldout);

                // Constant generation.
                EditorGUILayout.Space();
                EditorGUILayout.LabelField("CONSTANTS GENERATION", EditorStyles.boldLabel);
                EditorGUILayout.HelpBox(NotificationConstantGenerationIntro, MessageType.None);

                EditorGUILayout.Space();
                if (GUILayout.Button("Generate Constants Class", GUILayout.Height(EM_GUIStyleManager.buttonHeight)))
                {
                    GenerateNotificationConstants();
                }
            }

            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_PluginManager.DisableGameServiceModule(prefab);
                }
                else
                {
                    EM_PluginManager.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("GOOGLE PLAY GAMES SETUP", EditorStyles.boldLabel);

                // GPGPS debug log
                GameServiceProperties.gpgsDebugLog.property.boolValue = EditorGUILayout.Toggle(GameServiceProperties.gpgsDebugLog.content, GameServiceProperties.gpgsDebugLog.property.boolValue);

                // GPGS (optional) Web App Client ID.
                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Web App Client ID (Optional)", EditorStyles.boldLabel);
                EditorGUILayout.HelpBox("The web app client ID is needed to access the user's ID token and call other APIs on behalf of the user. It is not required for Game Services. " +
                                        "Enter your oauth2 client ID below. To obtain this ID, generate a web linked app in Developer Console.\n" +
                                        "Example: 123456789012-abcdefghijklm.apps.googleusercontent.com", MessageType.None);
                sGPGSWebClientId = EditorGUILayout.TextField("Web Client Id", sGPGSWebClientId);

                // Text area to input the Android Xml resource.
                EditorGUILayout.Space();
                EditorGUILayout.LabelField(GameServiceProperties.gpgsXmlResources.content, EditorStyles.boldLabel);
                EditorGUILayout.HelpBox(AndroidGPGPSSetupInstruction, MessageType.None);

                // Draw text area inside a scroll view.
                androidResourcesTextAreaScroll = GUILayout.BeginScrollView(androidResourcesTextAreaScroll, false, false, GUILayout.Height(EditorGUIUtility.singleLineHeight * 10));
                GameServiceProperties.gpgsXmlResources.property.stringValue = EditorGUILayout.TextArea(
                    GameServiceProperties.gpgsXmlResources.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)))
                {
                    EditorApplication.delayCall += SetupAndroidGPGSButtonHandler;
                }
                #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);
                }

                // Saved Games config.
                #if EASY_MOBILE_PRO
                EditorGUILayout.Space();
                EditorGUILayout.LabelField("SAVED GAMES CONFIG", EditorStyles.boldLabel);
                GameServiceProperties.enableSavedGames.property.boolValue = EditorGUILayout.Toggle(GameServiceProperties.enableSavedGames.content, GameServiceProperties.enableSavedGames.property.boolValue);

                if (GameServiceProperties.enableSavedGames.property.boolValue)
                {
                    EditorGUILayout.PropertyField(GameServiceProperties.autoConflictResolutionStrategy.property,
                                                  GameServiceProperties.autoConflictResolutionStrategy.content);

                    EditorGUILayout.PropertyField(GameServiceProperties.gpgsDataSource.property,
                                                  GameServiceProperties.gpgsDataSource.content);
                }
                #endif

                // 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 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();
        }
Example #10
0
        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();
        }