Exemplo n.º 1
0
        internal static void EnableAdModule(GameObject mainPrefab)
        {
            EM_EditorUtil.AddModuleToPrefab <AdManager>(mainPrefab);

            // Check ad network plugins' availability and define appropriate scripting symbols.
            List <string> symbols      = new List <string>();
            bool          isAdMobAvail = EM_ExternalPluginManager.IsAdMobAvail();

            if (isAdMobAvail)
            {
                symbols.Add(EM_ScriptingSymbols.AdMob);
            }

            bool isChartboostAvail = EM_ExternalPluginManager.IsChartboostAvail();

            if (isChartboostAvail)
            {
                symbols.Add(EM_ScriptingSymbols.Chartboost);
            }

            bool isHeyzapAvail = EM_ExternalPluginManager.IsHeyzapAvail();

            if (isHeyzapAvail)
            {
                symbols.Add(EM_ScriptingSymbols.Heyzap);
            }

            GlobalDefineManager.SDS_AddDefines(symbols.ToArray(), EditorUserBuildSettings.selectedBuildTargetGroup);
        }
 internal static void InstallPlayMakerActions(bool interactive)
 {
     if (!EM_ExternalPluginManager.IsPlayMakerAvail())
     {
         if (EM_EditorUtil.DisplayDialog(
                 "Installing PlayMaker Actions",
                 "Looks like you haven't installed PlayMaker, please install it to use these actions. " +
                 "Note that you also need to install the Unity UI add-on for PlayMaker to run Easy Mobile's PlayMaker demo.",
                 "Continue Anyway",
                 "Cancel"))
         {
             DoInstallPlayMakerActions(interactive);
         }
     }
     else
     {
         if (!EM_ExternalPluginManager.IsPlayMakerUguiAddOnAvail())
         {
             if (EM_EditorUtil.DisplayDialog(
                     "Installing PlayMaker Actions",
                     "Looks like you haven't installed the Unity UI add-on for PlayMaker. " +
                     "Please install it if you want to run Easy Mobile's PlayMaker demo.",
                     "Continue Anyway",
                     "Cancel"))
             {
                 DoInstallPlayMakerActions(interactive);
             }
         }
         else
         {
             DoInstallPlayMakerActions(interactive);
         }
     }
 }
Exemplo n.º 3
0
        internal static void DisableNotificationModule(GameObject mainPrefab)
        {
            EM_EditorUtil.RemoveModuleFromPrefab <NotificationManager>(mainPrefab);

            // Remove associated scripting symbol on all platforms it was defined.
            GlobalDefineManager.SDS_RemoveDefineOnAllPlatforms(EM_ScriptingSymbols.OneSignal);
        }
Exemplo n.º 4
0
        void DrawNotificationVibrationPattern(SerializedProperty vibrationPattern)
        {
            EditorGUILayout.BeginHorizontal();

            if (notificationVibrationPatternTooltip == null)
            {
                notificationVibrationPatternTooltip = EM_EditorUtil.GetFieldTooltip(typeof(NotificationCategory), NotificationCategory_VibrationPattern);
            }

            EditorGUILayout.LabelField(new GUIContent(vibrationPattern.displayName, notificationVibrationPatternTooltip));
            EditorGUI.BeginChangeCheck();
            vibrationPattern.arraySize = EditorGUILayout.IntField(vibrationPattern.arraySize, GUILayout.Width(50));
            if (EditorGUI.EndChangeCheck())
            {
                // Put a limit on the array size, who wants long patterns? :)
                vibrationPattern.arraySize = Mathf.Clamp(vibrationPattern.arraySize, 0, NotificationCategory_MaxVibrationPatternLength);
            }
            EditorGUILayout.EndHorizontal();

            EditorGUI.indentLevel++;
            for (int i = 0; i < vibrationPattern.arraySize; i++)
            {
                EditorGUILayout.PropertyField(vibrationPattern.GetArrayElementAtIndex(i));
            }
            EditorGUI.indentLevel--;
        }
Exemplo n.º 5
0
        internal static void DisableIAPModule(GameObject mainPrefab)
        {
            EM_EditorUtil.RemoveModuleFromPrefab <InAppPurchasing>(mainPrefab);

            // Remove associated scripting symbol on all platforms it was defined.
            GlobalDefineManager.SDS_RemoveDefineOnAllPlatforms(EM_ScriptingSymbols.UnityIAP);
        }
Exemplo n.º 6
0
        // Draw leaderboard or achievement item.
        void DrawGameServiceItem(SerializedProperty property, string label)
        {
            SerializedProperty name      = property.FindPropertyRelative(GameServiceItem_NameProperty);
            SerializedProperty iosId     = property.FindPropertyRelative(GameServiceItem_IOSIdProperty);
            SerializedProperty androidId = property.FindPropertyRelative(GameServiceItem_AndroidIdProperty);

            EditorGUILayout.BeginVertical(EM_GUIStyleManager.GetCustomStyle("Item Box"));

            EditorGUILayout.LabelField(string.IsNullOrEmpty(name.stringValue) ? "New " + label : name.stringValue, EditorStyles.boldLabel);
            name.stringValue  = EditorGUILayout.TextField("Name", name.stringValue);
            iosId.stringValue = EditorGUILayout.TextField("iOS Id", iosId.stringValue);
            // For Android Id, display a popup of Android leaderboards & achievements for the user to select
            // then assign its associated id to the property.
            EditorGUI.BeginChangeCheck();
            int currentIndex = Mathf.Max(System.Array.IndexOf(gpgsIds, EM_EditorUtil.GetKeyForValue(gpgsIdDict, androidId.stringValue)), 0);
            int newIndex     = EditorGUILayout.Popup("Android Id", currentIndex, gpgsIds);

            if (EditorGUI.EndChangeCheck())
            {
                // Position 0 is [None].
                if (newIndex == 0)
                {
                    androidId.stringValue = string.Empty;
                }
                else
                {
                    // Record the new android Id.
                    string newName = gpgsIds[newIndex];
                    androidId.stringValue = gpgsIdDict[newName];
                }
            }

            EditorGUILayout.EndVertical();
        }
Exemplo n.º 7
0
        void DrawNotificationActionButtonsArray(SerializedProperty actionButtons)
        {
            EditorGUILayout.BeginHorizontal();

            if (notificationActionButtonsTooltip == null)
            {
                notificationActionButtonsTooltip = EM_EditorUtil.GetFieldTooltip(typeof(NotificationCategory), NotificationCategory_ActionButtons);
            }

            EditorGUILayout.LabelField(new GUIContent(actionButtons.displayName, notificationActionButtonsTooltip));
            EditorGUI.BeginChangeCheck();
            actionButtons.arraySize = EditorGUILayout.IntField(actionButtons.arraySize, GUILayout.Width(50));
            if (EditorGUI.EndChangeCheck())
            {
                // Won't allow values larger than the maxminum number of buttons allowed.
                actionButtons.arraySize = Mathf.Clamp(actionButtons.arraySize, 0, NotificationCategory_MaxCustomButtons);
            }
            EditorGUILayout.EndHorizontal();

            EditorGUI.indentLevel++;
            for (int i = 0; i < actionButtons.arraySize; i++)
            {
                EditorGUILayout.PropertyField(actionButtons.GetArrayElementAtIndex(i));
            }
            EditorGUI.indentLevel--;
        }
Exemplo n.º 8
0
 /// <summary>
 /// Adds the scripting define symbols in the given array to all platforms where they don't exist.
 /// </summary>
 /// <param name="symbols">Symbols.</param>
 public static void SDS_AddDefinesOnAllPlatforms(string[] symbols)
 {
     foreach (BuildTargetGroup target in EM_EditorUtil.GetWorkingBuildTargetGroups())
     {
         SDS_AddDefines(symbols, target);
     }
 }
Exemplo n.º 9
0
        public static void InstallPlayMakerActions(bool interactive)
        {
            // First check if the PlayMaker Actions package has been imported.
            if (!FileIO.FileExists(PlayMakerActionsPackagePath))
            {
                if (EM_EditorUtil.DisplayDialog(
                        "PlayMaker Actions Not Found",
                        "Looks like you haven't imported the \"PlayMaker Actions for Easy Mobile Pro\" package. " +
                        "Please download and import it from the Unity Asset Store first.",
                        "Get it now",
                        "Later"))
                {
                    Application.OpenURL(PlayMakerActionsDownloadURL);
                }

                return;
            }

            // Check if PlayMaker itself has been installed.
            if (!EM_ExternalPluginManager.IsPlayMakerAvail())
            {
                if (EM_EditorUtil.DisplayDialog(
                        "Installing PlayMaker Actions",
                        "Looks like you haven't installed PlayMaker, please install it to use these actions.",
                        "Continue Anyway",
                        "Cancel"))
                {
                    DoInstallPlayMakerActions(interactive);
                }
            }
            else
            {
                DoInstallPlayMakerActions(interactive);
            }
        }
Exemplo n.º 10
0
 /// <summary>
 /// Removes the scripting define symbol on all platforms where it exists.
 /// </summary>
 /// <param name="symbol">Symbol.</param>
 public static void SDS_RemoveDefineOnAllPlatforms(string symbol)
 {
     foreach (BuildTargetGroup target in EM_EditorUtil.GetWorkingBuildTargetGroups())
     {
         SDS_RemoveDefine(symbol, target);
     }
 }
Exemplo n.º 11
0
        protected override void InternalEnableModule()
        {
            // Check if UnityIAP is enable and act accordingly.
            if (EM_ExternalPluginManager.IsUnityIAPAvail())
            {
                // Generate dummy AppleTangle and GoogleTangle classes if the "real" ones don't exist, to prevent
                // reference errors in InAppPurchasing receipt validation code.
                // If the actual tangles files are already generated, remove all dummy files if they exist.
                // Note that AppleTangle and GooglePlayTangle only get compiled on following platforms,
                // therefore the compilational condition is needed, otherwise the code will repeat forever.
                #if UNITY_ANDROID || UNITY_IPHONE || UNITY_STANDALONE_OSX || UNITY_TVOS
                if (!EM_EditorUtil.AppleTangleClassExists() && !EM_EditorUtil.DummyAppleTangleClassExists())
                {
                    EM_EditorUtil.GenerateDummyAppleTangleClass();
                }
                else if (EM_EditorUtil.AppleTangleClassExists())
                {
                    EM_EditorUtil.RemoveDummyAppleTangleClass();
                }

                if (!EM_EditorUtil.GooglePlayTangleClassExists() && !EM_EditorUtil.DummyGooglePlayTangleExists())
                {
                    EM_EditorUtil.GenerateDummyGooglePlayTangleClass();
                }
                else if (EM_EditorUtil.GooglePlayTangleClassExists())
                {
                    EM_EditorUtil.RemoveDummyGooglePlayTangleClass();
                }
                #endif

                GlobalDefineManager.SDS_AddDefineOnAllPlatforms(EM_ScriptingSymbols.UnityIAP);
            }
        }
Exemplo n.º 12
0
        internal static void EnableIAPModule(GameObject mainPrefab)
        {
            EM_EditorUtil.AddModuleToPrefab <IAPManager>(mainPrefab);

            // Check if UnityIAP is enable and act accordingly.
            bool isUnityIAPAvail = EM_ExternalPluginManager.IsUnityIAPAvail();

            if (isUnityIAPAvail)
            {
                // Generate dummy AppleTangle and GoogleTangle classes if they don't exist.
                // Note that AppleTangle and GooglePlayTangle only get compiled on following platforms,
                // therefore the compilational condition is needed, otherwise the code will repeat forever.
                #if UNITY_ANDROID || UNITY_IPHONE || UNITY_STANDALONE_OSX || UNITY_TVOS
                if (!EM_EditorUtil.AppleTangleClassExists())
                {
                    EM_EditorUtil.GenerateDummyAppleTangleClass();
                }

                if (!EM_EditorUtil.GooglePlayTangleClassExists())
                {
                    EM_EditorUtil.GenerateDummyGooglePlayTangleClass();
                }
                #endif

                GlobalDefineManager.SDS_AddDefine(EM_ScriptingSymbols.UnityIAP, EditorUserBuildSettings.selectedBuildTargetGroup);
            }
        }
Exemplo n.º 13
0
 /// Determindes if UnityAds plugin is available.
 /// </summary>
 /// <returns><c>true</c> if UnityAds plugin is available, otherwise <c>false</c>.</returns>
 public static bool IsUnityAdAvail()
 {
     if (!EM_Settings.Advertising.UnityAds.Enable)
     {
         return(false);
     }
     return(EM_EditorUtil.NamespaceExists(UnityAdNameSpace) && EM_EditorUtil.FindClass(UnityAdvertisementClass, UnityAdNameSpace) != null);
 }
 //Determindes if Vungle plugin is available.
 /// </summary>
 /// <returns><c>true</c> if Vungle plugin is available, otherwise <c>false</c>.</returns>
 public static bool IsVungleAvail()
 {
     if (!EM_Settings.Advertising.VungleAds.Enable)
     {
         return(false);
     }
     return(EM_EditorUtil.FindClass(VungleClassName) != null);
 }
Exemplo n.º 15
0
 /// <summary>
 /// Determines if AdColony plugin is available.
 /// </summary>
 /// <returns><c>true</c> if AdColony plugin available; otherwise, <c>false</c>.</returns>
 public static bool IsAdColonyAvail()
 {
     if (!EM_Settings.Advertising.AdColony.Enable)
     {
         return(false);
     }
     return(EM_EditorUtil.NamespaceExists(AdColonyNameSpace));
 }
Exemplo n.º 16
0
 /// Determines if Unity Monetization plugin is available.
 /// </summary>
 /// <returns><c>true</c> if Unity Monetization plugin is available, otherwise <c>false</c>.</returns>
 public static bool IsUnityMonetizationAvail()
 {
     if (!EM_Settings.Advertising.UnityAds.Enable)
     {
         return(false);
     }
     return(EM_EditorUtil.NamespaceExists(UnityMonetizationClass));
 }
Exemplo n.º 17
0
 /// Determines if IronSource plugin is available.
 /// </summary>
 public static bool IsIronSourceAvail()
 {
     if (!EM_Settings.Advertising.IronSource.Enable)
     {
         return(false);
     }
     return(EM_EditorUtil.FindClass(IronSourceClassname) != null);
 }
Exemplo n.º 18
0
 /// Determindes if TapJoy plugin is available.
 /// </summary>
 /// <returns><c>true</c> if TapJoy plugin is available, otherwise <c>false</c>.</returns>
 public static bool IsTapJoyAvail()
 {
     if (!EM_Settings.Advertising.Tapjoy.Enable)
     {
         return(false);
     }
     return(EM_EditorUtil.NamespaceExists(TapJoyNameSpace));
 }
Exemplo n.º 19
0
 /// <summary>
 /// Determines if FairBid plugin is available.
 /// </summary>
 /// <returns><c>true</c> if FairBid plugin available; otherwise, <c>false</c>.</returns>
 public static bool IsFairBidAvail()
 {
     if (!EM_Settings.Advertising.FairBid.Enable)
     {
         return(false);
     }
     return(EM_EditorUtil.NamespaceExists(FairBidNameSpace));
 }
Exemplo n.º 20
0
 /// <summary>
 /// Determines if MoPub plugin is available.
 /// </summary>
 /// <returns><c>true</c> if MoPub plugin is available; otherwise, <c>false</c>.</returns>
 public static bool IsMoPubAvail()
 {
     if (!EM_Settings.Advertising.MoPub.Enable)
     {
         return(false);
     }
     return(EM_EditorUtil.FindClass(MoPubClassName) != null);
 }
Exemplo n.º 21
0
 /// <summary>
 /// Determines if AppLovin plugin is available.
 /// </summary>
 /// <returns><c>true</c> if AppLovin plugin available; otherwise, <c>false</c>.</returns>
 public static bool IsAppLovinAvail()
 {
     if (!EM_Settings.Advertising.AppLovin.Enable)
     {
         return(false);
     }
     return(EM_EditorUtil.FindClass(AppLovinClassName) != null);
 }
Exemplo n.º 22
0
 /// <summary>
 /// Determines if Facebook Audience Network plugin is available.
 /// </summary>
 /// <returns></returns>
 public static bool IsFBAudienceAvail()
 {
     if (!EM_Settings.Advertising.AudienceNetwork.Enable)
     {
         return(false);
     }
     return(EM_EditorUtil.NamespaceExists(FBAudienceNameSpace));
 }
Exemplo n.º 23
0
 /// <summary>
 /// Determines if AdMob plugin is available.
 /// </summary>
 /// <returns><c>true</c> if AdMob plugin available; otherwise, <c>false</c>.</returns>
 public static bool IsAdMobAvail()
 {
     if (!EM_Settings.Advertising.AdMob.Enable)
     {
         return(false);
     }
     return(EM_EditorUtil.NamespaceExists(GoogleMobileAdsNameSpace));
 }
        private void GenerateAdIdsConstants()
        {
            Dictionary <string, string> finalResult = new Dictionary <string, string>();

            if (IsPluginAvail(AdNetwork.AdColony))
            {
                var adColonySettings = AdProperties.adColonySettings.GetTargetObject() as AdColonySettings;
                AddCustomAdsResource(finalResult, adColonySettings.CustomInterstitialAdIds, "AdColonyInterstitialAd");
                AddCustomAdsResource(finalResult, adColonySettings.CustomRewardedAdIds, "AdColonyRewardedAd");
            }

            if (IsPluginAvail(AdNetwork.AdMob))
            {
                var admobSettings = AdProperties.admobSettings.GetTargetObject() as AdMobSettings;
                AddCustomAdsResource(finalResult, admobSettings.CustomBannerAdIds, "AdmobBanner");
                AddCustomAdsResource(finalResult, admobSettings.CustomInterstitialAdIds, "AdmobInterstitialAd");
                AddCustomAdsResource(finalResult, admobSettings.CustomRewardedAdIds, "AdmobRewardedAd");
            }

            if (IsPluginAvail(AdNetwork.AudienceNetwork))
            {
                var fbAudienceSettings = AdProperties.fbAudienceSettings.GetTargetObject() as AudienceNetworkSettings;
                AddCustomAdsResource(finalResult, fbAudienceSettings.CustomBannerIds, "FBAudienceBanner");
                AddCustomAdsResource(finalResult, fbAudienceSettings.CustomInterstitialAdIds, "FBAudienceInterstitialAd");
                AddCustomAdsResource(finalResult, fbAudienceSettings.CustomRewardedAdIds, "FBAudienceRewardedAd");
            }

            if (IsPluginAvail(AdNetwork.MoPub))
            {
                var mopubSettings = AdProperties.mopubSettings.GetTargetObject() as MoPubSettings;
                AddCustomAdsResource(finalResult, mopubSettings.CustomBannerIds, "MopubBanner");
                AddCustomAdsResource(finalResult, mopubSettings.CustomInterstitialAdIds, "MopubInterstitialAd");
                AddCustomAdsResource(finalResult, mopubSettings.CustomRewardedAdIds, "MopubRewardedAd");
            }

            if (IsPluginAvail(AdNetwork.TapJoy))
            {
                var tapjoySettings = AdProperties.tapjoySettings.GetTargetObject() as TapjoySettings;
                AddCustomAdsResource(finalResult, tapjoySettings.CustomInterstitialAdIds, "TapjoyInterstitialAd");
                AddCustomAdsResource(finalResult, tapjoySettings.CustomRewardedAdIds, "TapjoyRewardedAd");
            }

            if (finalResult.Count > 0)
            {
                var hashtable = new Hashtable(finalResult);

                EM_EditorUtil.GenerateConstantsClass(
                    EM_Constants.GeneratedFolder,
                    EM_Constants.RootNameSpace + "." + EM_Constants.AdvertisingConstantsClassName,
                    new Hashtable(hashtable),
                    true
                    );
            }
            else
            {
                Debug.Log("There is no custom ad to generate.");
            }
        }
Exemplo n.º 25
0
        // Draw the array of leaderboards or achievements inside a foldout and the relevant buttons.
        void DrawGameServiceItemArray(string itemType, EMProperty myProp, ref bool isFoldout)
        {
            if (myProp.property.arraySize > 0)
            {
                EditorGUI.indentLevel++;
                isFoldout = EditorGUILayout.Foldout(isFoldout, myProp.property.arraySize + " " + myProp.content.text);
                EditorGUI.indentLevel--;

                if (isFoldout)
                {
                    // Update the string array of Android GPGPS ids to display in the leaderboards and achievements.
                    gpgsIds    = new string[gpgsIdDict.Count + 1];
                    gpgsIds[0] = EM_Constants.NoneSymbol;
                    gpgsIdDict.Keys.CopyTo(gpgsIds, 1);

                    System.Action <SerializedProperty> drawer;

                    if (itemType.Equals("Leaderboard"))
                    {
                        drawer = DrawGameServiceLeaderboard;
                    }
                    else if (itemType.Equals("Achievement"))
                    {
                        drawer = DrawGameServiceAchievement;
                    }
                    else
                    {
                        throw new System.Exception("Invalid itemType");
                    }

                    // Draw the array of achievements or leaderboards.
                    DrawArrayProperty(myProp.property, drawer);

                    // Detect duplicate names.
                    string duplicateName = EM_EditorUtil.FindDuplicateFieldInArrayProperty(myProp.property, GameServiceItem_NameProperty);
                    if (!string.IsNullOrEmpty(duplicateName))
                    {
                        EditorGUILayout.Space();
                        EditorGUILayout.HelpBox("Found duplicate name of \"" + duplicateName + "\".", MessageType.Warning);
                    }
                }
            }
            else
            {
                EditorGUILayout.HelpBox("No " + itemType + " added.", MessageType.None);
            }

            EditorGUILayout.Space();
            if (GUILayout.Button("Add New " + itemType, GUILayout.Height(EM_GUIStyleManager.buttonHeight)))
            {
                // Add new leaderboard.
                AddNewGameServiceItem(myProp.property);

                // Open the foldout if it's closed.
                isFoldout = true;
            }
        }
Exemplo n.º 26
0
 /// <summary>
 /// Determines if Chartboost plugin is available.
 /// </summary>
 /// <returns><c>true</c> if Chartboost plugin available; otherwise, <c>false</c>.</returns>
 public static bool IsChartboostAvail()
 {
     if (!EM_Settings.Advertising.Chartboost.Enable)
     {
         return(false);
     }
     System.Type chartboost = EM_EditorUtil.FindClass(ChartboostClassName, ChartboostNameSpace);
     return(chartboost != null);
 }
Exemplo n.º 27
0
        /// <summary>
        /// Determines if UnityIAP is enabled.
        /// </summary>
        /// <returns><c>true</c> if enabled; otherwise, <c>false</c>.</returns>
        public static bool IsUnityIAPAvail()
        {
//            System.Type purchasing = EM_EditorUtil.FindClass(UnityPurchasingClassName, UnityPurchasingNameSpace, UnityPurchasingAssemblyName);
//            return purchasing != null;

            // Here we check for the existence of the Security namespace instead of UnityPurchasing class in order to
            // make sure that the plugin is actually imported (rather than the service just being enabled).
            return(EM_EditorUtil.NamespaceExists(UnityPurchasingSecurityNameSpace));
        }
Exemplo n.º 28
0
        internal static void DisableAdModule(GameObject mainPrefab)
        {
            EM_EditorUtil.RemoveModuleFromPrefab <AdManager>(mainPrefab);

            // Remove associated scripting symbols on all platforms if any was defined on that platform.
            GlobalDefineManager.SDS_RemoveDefinesOnAllPlatforms(
                new string[] { EM_ScriptingSymbols.AdMob, EM_ScriptingSymbols.Chartboost, EM_ScriptingSymbols.Heyzap }
                );
        }
Exemplo n.º 29
0
        public static bool IsPlayServicesResolverImported()
        {
            var imported = EM_ProjectSettings.Instance.GetBool(EM_Constants.PSK_ImportedPlayServicesResolver, false);

            var iosResolver     = EM_EditorUtil.FindClass(IosResolverClass, GoogleNameSpace);
            var jarResolver     = EM_EditorUtil.FindClass(JarResolverDependencyClass, JarResolverNamespace);
            var packageResolver = EM_EditorUtil.FindClass(PackageManagerResolverClass, GoogleNameSpace);

            return(iosResolver != null || jarResolver != null || packageResolver != null || imported);
        }
Exemplo n.º 30
0
        internal static void DisableGameServiceModule(GameObject mainPrefab)
        {
            EM_EditorUtil.RemoveModuleFromPrefab <GameServiceManager>(mainPrefab);

            // Removed associated scripting symbols if any was defined.
            // Note that we won't remove the NO_GPGS symbol automatically on iOS.
            // Rather we'll let the user delete it manually if they want.
            // This helps prevent potential build issues on iOS due to GPGS dependencies.
            GlobalDefineManager.SDS_RemoveDefineOnAllPlatforms(EM_ScriptingSymbols.GooglePlayGames);
        }