// This static constructor will automatically run thanks to the InitializeOnLoad attribute.
        static EM_PluginManager()
        {
            EditorApplication.update += Initialize;
            bool compilerErrorFound = false;

            CompilationPipeline.assemblyCompilationFinished += (outputPath, compilerMessages) =>
            {
                foreach (var msg in compilerMessages)
                {
                    if (msg.type == CompilerMessageType.Error && (msg.message.Contains("CS0246") || msg.message.Contains("CS0006")))
                    {
                        compilerErrorFound = true;
                    }
                }

                string lastDefine    = EditorPrefs.GetString(PreviousUnsuccessfulDefines, "");
                string currentDefine = PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup);
                if (compilerErrorFound && lastDefine != currentDefine)
                {
                    //try to remove #defind since there was an error while compiling
                    //in case the current define symbols are the same as last time => not reset symbols since it might be other party problems
                    //and to avoid enless recompiling if that was the case
                    EditorPrefs.SetString(PreviousUnsuccessfulDefines, currentDefine);
                    GlobalDefineManager.SDS_RemoveDefinesOnAllPlatforms(EM_ScriptingSymbols.GetAllSymbols());
                }
            };
        }
Exemple #2
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);
        }
        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 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);
            }
        }
        protected override void InternalDisableSubmodule(Submodule submod)
        {
#if EASY_MOBILE_PRO
            if (submod == Submodule.Contacts)
            {
                // Exclude iOS native lib for Contacts.
                var pluginImporter = AssetImporter.GetAtPath(iOSContactsLibPath) as PluginImporter;
                pluginImporter.ClearSettings();
                pluginImporter.SetCompatibleWithAnyPlatform(false);

                // Remove associated scripting symbol on all platforms it was defined.
                GlobalDefineManager.SDS_RemoveDefineOnAllPlatforms(EM_ScriptingSymbols.ContactsSubmodule);
            }
            else if (submod == Submodule.Media)
            {
                // Exclude iOS native lib for Camera & Gallery.
                var pluginImporter = AssetImporter.GetAtPath(iOSCameraGalleryLibPath) as PluginImporter;
                pluginImporter.ClearSettings();
                pluginImporter.SetCompatibleWithAnyPlatform(false);

                // Remove associated scripting symbol on all platforms it was defined.
                GlobalDefineManager.SDS_RemoveDefineOnAllPlatforms(EM_ScriptingSymbols.CameraGallerySubmodule);
            }
#endif
        }
        protected override void InternalEnableSubmodule(Submodule submod)
        {
#if EASY_MOBILE_PRO
            if (submod == Submodule.Contacts)
            {
                // Include iOS native lib for Contacts.
                var pluginImporter = AssetImporter.GetAtPath(iOSContactsLibPath) as PluginImporter;
                pluginImporter.ClearSettings();
                pluginImporter.SetCompatibleWithAnyPlatform(false);
                pluginImporter.SetCompatibleWithPlatform(BuildTarget.iOS, true);

                // Define scripting symbol.
                GlobalDefineManager.SDS_AddDefineOnAllPlatforms(EM_ScriptingSymbols.ContactsSubmodule);
            }
            else if (submod == Submodule.Media)
            {
                // Include iOS native lib for Camera & Gallery.
                var pluginImporter = AssetImporter.GetAtPath(iOSCameraGalleryLibPath) as PluginImporter;
                pluginImporter.ClearSettings();
                pluginImporter.SetCompatibleWithAnyPlatform(false);
                pluginImporter.SetCompatibleWithPlatform(BuildTarget.iOS, true);

                // Define scripting symbol.
                GlobalDefineManager.SDS_AddDefineOnAllPlatforms(EM_ScriptingSymbols.CameraGallerySubmodule);
            }
#endif
        }
        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);
        }
Exemple #8
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);
            }
        }
 internal static void DisableGameServiceModule()
 {
     // 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);
 }
        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 }
                );
        }
        protected override void InternalDisableSubmodule(Submodule submod)
        {
            // Exclude iOS native lib for Contacts.
            var pluginImporter = AssetImporter.GetAtPath(iOSATTLibPath) as PluginImporter;

            pluginImporter.ClearSettings();
            pluginImporter.SetCompatibleWithAnyPlatform(false);

            // Remove associated scripting symbol on all platforms it was defined.
            GlobalDefineManager.SDS_RemoveDefineOnAllPlatforms(EM_ScriptingSymbols.AppTrackingSubmodule);
        }
        protected override void InternalEnableSubmodule(Submodule submod)
        {
            // Include iOS native lib for Contacts.
            var pluginImporter = AssetImporter.GetAtPath(iOSATTLibPath) as PluginImporter;

            pluginImporter.ClearSettings();
            pluginImporter.SetCompatibleWithAnyPlatform(false);
            pluginImporter.SetCompatibleWithPlatform(BuildTarget.iOS, true);

            // Define scripting symbol.
            GlobalDefineManager.SDS_AddDefineOnAllPlatforms(EM_ScriptingSymbols.AppTrackingSubmodule);
        }
        internal static void EnableNotificationModule(GameObject mainPrefab)
        {
            EM_EditorUtil.AddModuleToPrefab <NotificationManager>(mainPrefab);

            // Check if OneSignal is available.
            bool isOneSignalAvail = EM_ExternalPluginManager.IsOneSignalAvail();

            if (isOneSignalAvail)
            {
                GlobalDefineManager.SDS_AddDefine(EM_ScriptingSymbols.OneSignal, EditorUserBuildSettings.selectedBuildTargetGroup);
            }
        }
        protected override void InternalEnableModule()
        {
            List <string> symbols = new List <string>();

            if (EM_ExternalPluginManager.IsUsingURP())
            {
                symbols.Add(EM_ScriptingSymbols.UniversalRenderPipeline);
            }

            // Defines all ad symbols on all platforms.
            GlobalDefineManager.SDS_AddDefinesOnAllPlatforms(symbols.ToArray());
        }
        internal static void EnableGameServiceModule()
        {
            // Check if Google Play Games plugin is available.
            bool isGPGSAvail = EM_ExternalPluginManager.IsGPGSAvail();

            if (isGPGSAvail)
            {
                // We won't use Google Play Game Services on iOS, so we'll define NO_GPGS symbol to disable it
                // (if needed, as newer versions of GPGS defines this themselves).
                GlobalDefineManager.SDS_AddDefine(EM_ScriptingSymbols.NoGooglePlayGames, BuildTargetGroup.iOS);

                // Define EM_GPGS symbol on Android platform
                GlobalDefineManager.SDS_AddDefine(EM_ScriptingSymbols.GooglePlayGames, BuildTargetGroup.Android);
            }
        }
 internal static void DisableAdModule()
 {
     // Remove associated scripting symbols on all platforms if any was defined on that platform.
     GlobalDefineManager.SDS_RemoveDefinesOnAllPlatforms(
         new string[]
     {
         EM_ScriptingSymbols.AdColony,
         EM_ScriptingSymbols.AdMob,
         EM_ScriptingSymbols.Chartboost,
         EM_ScriptingSymbols.FBAudience,
         EM_ScriptingSymbols.IronSource,
         EM_ScriptingSymbols.Heyzap,
         EM_ScriptingSymbols.MoPub,
         EM_ScriptingSymbols.TapJoy
     });
 }
        internal static void EnableGameServiceModule(GameObject mainPrefab)
        {
            EM_EditorUtil.AddModuleToPrefab <GameServiceManager>(mainPrefab);

            // Check if Google Play Games plugin is available.
            bool isGPGSAvail = EM_ExternalPluginManager.IsGPGSAvail();

            if (isGPGSAvail)
            {
                // We won't use Google Play Game Services on iOS, so we'll define NO_GPGS symbol to disable it.
                GlobalDefineManager.SDS_AddDefine(EM_ScriptingSymbols.NoGooglePlayGames, BuildTargetGroup.iOS);

                // Define EM_GPGS symbol on Android platform
                GlobalDefineManager.SDS_AddDefine(EM_ScriptingSymbols.GooglePlayGames, BuildTargetGroup.Android);
            }
        }
Exemple #18
0
        private static void Initialize()
        {
            EditorApplication.update -= Initialize;

            // Check if a new version has been imported and perform necessary updating jobs.
            VersionCheck();

            // Define a global symbol indicating the existence of EasyMobile.
            GlobalDefineManager.SDS_AddDefinesOnAllPlatforms(EM_ScriptingSymbols.EasyMobile.Split(';'));

            // Create the EM_Settings scriptable object if it doesn't exist.
            EM_BuiltinObjectCreator.CreateEMSettingsAsset();

            // Regularly check for module prerequisites to avoid issues caused
            // by inadvertent changes, e.g removal of required scripting symbols.
            CheckModules();
        }
 protected override void InternalDisableModule()
 {
     // Remove associated scripting symbols on all platforms if any was defined on that platform.
     GlobalDefineManager.SDS_RemoveDefinesOnAllPlatforms(
         new string[]
     {
         EM_ScriptingSymbols.AdColony,
         EM_ScriptingSymbols.AdMob,
         EM_ScriptingSymbols.AppLovin,
         EM_ScriptingSymbols.FBAudience,
         EM_ScriptingSymbols.Chartboost,
         EM_ScriptingSymbols.Heyzap,
         EM_ScriptingSymbols.IronSource,
         EM_ScriptingSymbols.MoPub,
         EM_ScriptingSymbols.TapJoy,
         EM_ScriptingSymbols.UnityMonetization
     });
 }
Exemple #20
0
        internal static void EnableAdModule(GameObject mainPrefab)
        {
            EM_EditorUtil.AddModuleToPrefab <Advertising>(mainPrefab);

            // Check ad network plugins' availability and define appropriate scripting symbols.
            // Note that UnityAds symbol is added automatically by Unity engine.
            List <string> symbols = new List <string>();

            // AdColony
            bool isAdColonyAvail = EM_ExternalPluginManager.IsAdColonyAvail();

            if (isAdColonyAvail)
            {
                symbols.Add(EM_ScriptingSymbols.AdColony);
            }

            // AdMob
            bool isAdMobAvail = EM_ExternalPluginManager.IsAdMobAvail();

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

            // Chartboost
            bool isChartboostAvail = EM_ExternalPluginManager.IsChartboostAvail();

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

            // Heyzap
            bool isHeyzapAvail = EM_ExternalPluginManager.IsHeyzapAvail();

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

            GlobalDefineManager.SDS_AddDefines(symbols.ToArray(), EditorUserBuildSettings.selectedBuildTargetGroup);
        }
Exemple #21
0
        private static void Initialize()
        {
            EditorApplication.update -= Initialize;

            // Check if a new version has been imported and perform necessary updating jobs.
            VersionCheck();

            // Define a global symbol indicating the existence of EasyMobile
            GlobalDefineManager.SDS_AddDefines(EM_ScriptingSymbols.EasyMobile.Split(';'), EditorUserBuildSettings.selectedBuildTargetGroup);

            // Create the EM_Settings scriptable object if it doesn't exist.
            EM_BuiltinObjectCreator.CreateEMSettingsAsset();

            // Create the EasyMobile prefab if it doesn't exist.
            EM_BuiltinObjectCreator.CreateEasyMobilePrefab();

            // Regularly check for module prerequisites to avoid issues caused
            // by inadvertent changes, e.g remove components from prefab or delete scripting symbol.
            CheckModules();
        }
        internal static void EnableNotificationModule()
        {
            // Define related symbols.
            var symbols = new List <string>();

            // Check if OneSignal is available.
            if (EM_ExternalPluginManager.IsOneSignalAvail())
            {
                symbols.Add(EM_ScriptingSymbols.OneSignal);
            }

            // Check if Firebase Messaging is available.
            if (EM_ExternalPluginManager.IsFirebaseMessagingAvail())
            {
                symbols.Add(EM_ScriptingSymbols.FirebaseMessaging);
            }

            // Define the symbols on all platforms.
            GlobalDefineManager.SDS_AddDefinesOnAllPlatforms(symbols.ToArray());
        }
        protected override void InternalEnableModule()
        {
            // Check if UnityIAP is enable and act accordingly.
            if (EM_ExternalPluginManager.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_AddDefineOnAllPlatforms(EM_ScriptingSymbols.UnityIAP);
            }
        }
        private static void Initialize()
        {
            EditorApplication.update -= Initialize;

            // Import the native package if it has been imported before.
            if (!IsNativeCodeImported())
            {
                ImportNativeCode();
            }

            // Define a global symbol indicating the existence of EasyMobile
            GlobalDefineManager.SDS_AddDefine(EM_ScriptingSymbols.EasyMobile, EditorUserBuildSettings.selectedBuildTargetGroup);

            // Create the EM_Settings scriptable object if it doesn't exist.
            CreateSettingsAsset();

            // Create the EasyMobile prefab if it doesn't exist.
            CreateMainPrefab();

            // Regularly check for module prerequisites to avoid issues caused
            // by inadvertent changes, e.g remove components from prefab or delete scripting symbol.
            CheckModules();
        }
 protected override void InternalDisableModule()
 {
     // Remove associated scripting symbol on all platforms it was defined.
     GlobalDefineManager.SDS_RemoveDefineOnAllPlatforms(EM_ScriptingSymbols.UnityIAP);
 }
        protected override void InternalEnableModule()
        {
            // Check ad network plugins' availability and define appropriate scripting symbols.
            // Note that UnityAds symbol is added automatically by Unity engine.
            List <string> symbols = new List <string>();

            // AdColony
            if (EM_ExternalPluginManager.IsAdColonyAvail())
            {
                symbols.Add(EM_ScriptingSymbols.AdColony);
            }

            // AdMob
            if (EM_ExternalPluginManager.IsAdMobAvail())
            {
                symbols.Add(EM_ScriptingSymbols.AdMob);
            }

            // AdMob
            if (EM_ExternalPluginManager.IsAppLovinAvail())
            {
                symbols.Add(EM_ScriptingSymbols.AppLovin);
            }

            // FB Audience
            if (EM_ExternalPluginManager.IsFBAudienceAvail())
            {
                symbols.Add(EM_ScriptingSymbols.FBAudience);
            }

            // Chartboost
            if (EM_ExternalPluginManager.IsChartboostAvail())
            {
                symbols.Add(EM_ScriptingSymbols.Chartboost);
            }

            // FairBid
            if (EM_ExternalPluginManager.IsFairBidAvail())
            {
                symbols.Add(EM_ScriptingSymbols.FairBid);
            }

            // IronSource
            if (EM_ExternalPluginManager.IsIronSourceAvail())
            {
                symbols.Add(EM_ScriptingSymbols.IronSource);
            }

            // MoPub
            if (EM_ExternalPluginManager.IsMoPubAvail())
            {
                symbols.Add(EM_ScriptingSymbols.MoPub);
            }

            // TapJoy
            if (EM_ExternalPluginManager.IsTapJoyAvail())
            {
                symbols.Add(EM_ScriptingSymbols.TapJoy);
            }

            // Unity Monetization
            if (EM_ExternalPluginManager.IsUnityMonetizationAvail())
            {
                symbols.Add(EM_ScriptingSymbols.UnityMonetization);
            }

            // Unity Ads
            if (EM_ExternalPluginManager.IsUnityAdAvail())
            {
                symbols.Add(EM_ScriptingSymbols.UnityAds);
            }

            // Vungle
            if (EM_ExternalPluginManager.IsVungleAvail())
            {
                symbols.Add(EM_ScriptingSymbols.Vungle);
            }

            // Defines all ad symbols on all platforms.
            GlobalDefineManager.SDS_AddDefinesOnAllPlatforms(symbols.ToArray());
        }
        internal static void EnableAdModule()
        {
            // Check ad network plugins' availability and define appropriate scripting symbols.
            // Note that UnityAds symbol is added automatically by Unity engine.
            List <string> symbols = new List <string>();

            // AdColony
            bool isAdColonyAvail = EM_ExternalPluginManager.IsAdColonyAvail();

            if (isAdColonyAvail)
            {
                symbols.Add(EM_ScriptingSymbols.AdColony);
            }

            // AdMob
            bool isAdMobAvail = EM_ExternalPluginManager.IsAdMobAvail();

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

            // Chartboost
            bool isChartboostAvail = EM_ExternalPluginManager.IsChartboostAvail();

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

            // FB Audience
            if (EM_ExternalPluginManager.IsFBAudienceAvail())
            {
                symbols.Add(EM_ScriptingSymbols.FBAudience);
            }

            // IronSource
            if (EM_ExternalPluginManager.IsIronSourceAvail())
            {
                symbols.Add(EM_ScriptingSymbols.IronSource);
            }

            // Heyzap
            bool isHeyzapAvail = EM_ExternalPluginManager.IsHeyzapAvail();

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

            // MoPub
            if (EM_ExternalPluginManager.IsMoPubAvail())
            {
                symbols.Add(EM_ScriptingSymbols.MoPub);
            }

            // TapJoy
            if (EM_ExternalPluginManager.IsTapJoyAvail())
            {
                symbols.Add(EM_ScriptingSymbols.TapJoy);
            }

            // Unity Ads defines a symbol themselves.

            // Defines all ad symbols on all platforms.
            GlobalDefineManager.SDS_AddDefinesOnAllPlatforms(symbols.ToArray());
        }
 internal static void DisableNotificationModule()
 {
     // Remove associated scripting symbol on all platforms it was defined.
     GlobalDefineManager.SDS_RemoveDefinesOnAllPlatforms(
         new string[] { EM_ScriptingSymbols.OneSignal, EM_ScriptingSymbols.FirebaseMessaging });
 }
 internal static void DisableIAPModule()
 {
     // Remove associated scripting symbol on all platforms it was defined.
     GlobalDefineManager.SDS_RemoveDefineOnAllPlatforms(EM_ScriptingSymbols.UnityIAP);
 }
Exemple #30
0
 protected override void InternalDisableModule()
 {
     // Remove associated scripting symbol on all platforms it was defined.
     GlobalDefineManager.SDS_RemoveDefinesOnAllPlatforms(
         new string[] { EM_ScriptingSymbols.OneSignal, EM_ScriptingSymbols.FirebaseMessaging });
 }