示例#1
0
        // Makes that everything is set up properly so that all modules function as expected.
        internal static void CheckModules()
        {
            GameObject mainPrefab = EM_EditorUtil.GetMainPrefab();

            // Notification module
            if (EM_Settings.IsNotificationModuleEnable)
            {
                EnableNotificationModule(mainPrefab);
            }
            else
            {
                DisableNotificationModule(mainPrefab);
            }
        }
        private static GameObject CreateMainPrefab(bool showAlert = false)
        {
            // Stop if the prefab is already created.
            string     prefabPath     = EM_Constants.MainPrefabPath;
            GameObject existingPrefab = EM_EditorUtil.GetMainPrefab();

            if (existingPrefab != null)
            {
                if (showAlert)
                {
                    EM_EditorUtil.Alert("Prefab Exists", "EasyMobile.prefab already exists at " + prefabPath);
                }

                return(existingPrefab);
            }

            // Make sure the containing folder exists.
            FileIO.EnsureFolderExists(EM_Constants.MainPrefabFolder);

            // Create a temporary gameObject and then create the prefab from it.
            GameObject tmpObj = new GameObject(EM_Constants.MainPrefabName);

            // Add PrefabManager component.
            tmpObj.AddComponent <EM_PrefabManager>();

            // Generate the prefab from the temporary game object.
            GameObject prefabObj = PrefabUtility.CreatePrefab(prefabPath, tmpObj);

            GameObject.DestroyImmediate(tmpObj);

            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();

            if (showAlert)
            {
                EM_EditorUtil.Alert("Prefab Created", "EasyMobile.prefab is created at " + prefabPath);
            }
            else
            {
                Debug.Log("EasyMobile.prefab is created at " + prefabPath);
            }

            return(prefabObj);
        }
        // Makes that everything is set up properly so that all modules function as expected.
        internal static void CheckModules()
        {
            GameObject mainPrefab = EM_EditorUtil.GetMainPrefab();

            // Advertising module.
            if (EM_Settings.IsAdModuleEnable)
            {
                EnableAdModule(mainPrefab);
            }
            else
            {
                DisableAdModule(mainPrefab);
            }

            // IAP module.
            if (EM_Settings.IsIAPModuleEnable)
            {
                EnableIAPModule(mainPrefab);
            }
            else
            {
                DisableIAPModule(mainPrefab);
            }

            // Game Service module.
            if (EM_Settings.IsGameServiceModuleEnable)
            {
                EnableGameServiceModule(mainPrefab);
            }
            else
            {
                DisableGameServiceModule(mainPrefab);
            }

            // Notification module
            if (EM_Settings.IsNotificationModuleEnable)
            {
                EnableNotificationModule(mainPrefab);
            }
            else
            {
                DisableNotificationModule(mainPrefab);
            }
        }
示例#4
0
        public static void PreBuildProcessing(BuildTarget target, string path)
        {
            // Search through all enabled scenes in the BuildSettings to find the EasyMobile prefab instance.
            // Warn the user if none was found.
            GameObject prefab = EM_EditorUtil.GetMainPrefab();

            if (prefab != null)
            {
                string[] enabledScenePaths = EM_EditorUtil.GetScenePathInBuildSettings(true);
                if (!EM_EditorUtil.IsPrefabInstanceFoundInScenes(prefab, enabledScenePaths))
                {
                    string title = "EasyMobile Instance Missing";
                    string msg   = "No root-level instance of the EasyMobile prefab was found in the enabled scene(s). " +
                                   "Please add one to the first scene of your game for the plugin to function properly.";
                    #if !UNITY_CLOUD_BUILD
                    EM_EditorUtil.Alert(title, msg);
                    #else
                    Debug.LogWarning(msg);
                    #endif
                }
            }
        }
示例#5
0
        public static void CreateEasyMobilePrefabInstance(MenuCommand menuCommand)
        {
            GameObject prefab = EM_EditorUtil.GetMainPrefab();

            if (prefab == null)
            {
                prefab = EM_BuiltinObjectCreator.CreateEasyMobilePrefab();
            }

            // Stop if another instance already exists as a root object in this scene
            GameObject existingInstance = EM_EditorUtil.FindPrefabInstanceInScene(prefab, EditorSceneManager.GetActiveScene());

            if (existingInstance != null)
            {
                Selection.activeObject = existingInstance;
                return;
            }

            // Instantiate an EasyMobile prefab at scene root (parentless) because it's a singleton
            GameObject go = PrefabUtility.InstantiatePrefab(prefab) as GameObject;

            AddGameObjectToScene(go);
        }
示例#6
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();
        }
示例#8
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();
        }
示例#9
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();
        }
示例#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_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();
        }
示例#11
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();
        }