Example #1
0
        private static void ShowGoogleNetworkAdaptersUpdateDialogIfNeeded(Network[] networks)
        {
            // AdMob and GAM use the same SDKs so their adapters should use the same underlying SDK version.
            var googleNetwork          = networks.FirstOrDefault(network => network.Name.Equals("ADMOB_NETWORK"));
            var googleAdManagerNetwork = networks.FirstOrDefault(network => network.Name.Equals("GOOGLE_AD_MANAGER_NETWORK"));

            // If both AdMob and GAM are not integrated, do nothing.
            if (googleNetwork == null || string.IsNullOrEmpty(googleNetwork.CurrentVersions.Unity) ||
                googleAdManagerNetwork == null || string.IsNullOrEmpty(googleAdManagerNetwork.CurrentVersions.Unity))
            {
                return;
            }

            var isAndroidVersionCompatible = GoogleNetworkAdaptersCompatible(googleNetwork.CurrentVersions.Android, googleAdManagerNetwork.CurrentVersions.Android, "19.8.0.0");
            var isIosVersionCompatible     = GoogleNetworkAdaptersCompatible(googleNetwork.CurrentVersions.Ios, googleAdManagerNetwork.CurrentVersions.Ios, "8.0.0.0");

            if (isAndroidVersionCompatible && isIosVersionCompatible)
            {
                return;
            }

            var message = "You may see unexpected errors if you use different versions of the AdMob and Google Ad Manager adapter SDKs. " +
                          "AdMob and Google Ad Manager share the same SDKs.\n\n" +
                          "You can be sure that you are using the same SDK for both if the first three numbers in each adapter version match.";

            AppLovinIntegrationManager.ShowBuildFailureDialog(message);
        }
        private void OnImportPackageCompleted(Network network)
        {
            var parentDirectory = network.Name.Equals("APPLOVIN_NETWORK") ? AppLovinIntegrationManager.PluginParentDirectory : AppLovinIntegrationManager.MediationSpecificPluginParentDirectory;

            AppLovinIntegrationManager.UpdateCurrentVersions(network, parentDirectory);

            UpdateShouldShowGoogleWarningIfNeeded();
        }
Example #3
0
        private static void ShowNetworkAdaptersUpdateDialogIfNeeded(Network[] networks)
        {
            var networksToUpdate = networks.Where(network => network.RequiresUpdate).ToList();

            // If all networks are above the required version, do nothing.
            if (networksToUpdate.Count <= 0)
            {
                return;
            }

            // We found a few adapters that are not compatible with the current SDK, show alert.
            var message = "The following network adapters are not compatible with the current version of AppLovin MAX Plugin:\n";

            foreach (var networkName in networksToUpdate)
            {
                message += "\n- ";
                message += networkName.DisplayName + " (Requires " + MinAdapterVersions[networkName.Name] + " or newer)";
            }

            message += "\n\nPlease update them to the latest versions to avoid any issues.";

            AppLovinIntegrationManager.ShowBuildFailureDialog(message);
        }
        /// <summary>
        /// Draws the network specific details for a given network.
        /// </summary>
        private void DrawNetworkDetailRow(Network network)
        {
            string action;
            var    currentVersion = network.CurrentVersions.Unity;
            var    latestVersion  = network.LatestVersions.Unity;
            bool   isActionEnabled;
            bool   isInstalled;

            if (string.IsNullOrEmpty(currentVersion))
            {
                action          = "Install";
                currentVersion  = "Not Installed";
                isActionEnabled = true;
                isInstalled     = false;
            }
            else
            {
                isInstalled = true;

                var comparison = network.CurrentToLatestVersionComparisonResult;
                // A newer version is available
                if (comparison == VersionComparisonResult.Lesser)
                {
                    action          = "Upgrade";
                    isActionEnabled = true;
                }
                // Current installed version is newer than latest version from DB (beta version)
                else if (comparison == VersionComparisonResult.Greater)
                {
                    action          = "Installed";
                    isActionEnabled = false;
                }
                // Already on the latest version
                else
                {
                    action          = "Installed";
                    isActionEnabled = false;
                }
            }

            GUILayout.Space(4);
            using (new EditorGUILayout.HorizontalScope(GUILayout.ExpandHeight(false)))
            {
                GUILayout.Space(5);
                EditorGUILayout.LabelField(new GUIContent(network.DisplayName), networkWidthOption);
                EditorGUILayout.LabelField(new GUIContent(currentVersion), versionWidthOption);
                GUILayout.Space(3);
                EditorGUILayout.LabelField(new GUIContent(latestVersion), versionWidthOption);
                GUILayout.Space(3);
                GUILayout.FlexibleSpace();

                if (network.RequiresUpdate)
                {
                    GUILayout.Label(new GUIContent {
                        image = alertIcon, tooltip = "Adapter not compatible, please update to the latest version."
                    }, iconStyle);
                }
                else if ((network.Name.Equals("ADMOB_NETWORK") || network.Name.Equals("GOOGLE_AD_MANAGER_NETWORK")) && shouldShowGoogleWarning)
                {
                    GUILayout.Label(new GUIContent {
                        image = warningIcon, tooltip = "You may see unexpected errors if you use different versions of the AdMob and Google Ad Manager adapter SDKs."
                    }, iconStyle);
                }

                GUI.enabled = isActionEnabled;
                if (GUILayout.Button(new GUIContent(action), fieldWidth))
                {
                    // Download the plugin.
                    AppLovinEditorCoroutine.StartCoroutine(AppLovinIntegrationManager.Instance.DownloadPlugin(network));
                }

                GUI.enabled = true;
                GUILayout.Space(2);

                GUI.enabled = isInstalled;
                if (GUILayout.Button(new GUIContent {
                    image = uninstallIcon, tooltip = "Uninstall"
                }, iconStyle))
                {
                    EditorUtility.DisplayProgressBar("Integration Manager", "Deleting " + network.Name + "...", 0.5f);
                    var pluginRoot = AppLovinIntegrationManager.MediationSpecificPluginParentDirectory;
                    foreach (var pluginFilePath in network.PluginFilePaths)
                    {
                        FileUtil.DeleteFileOrDirectory(Path.Combine(pluginRoot, pluginFilePath));
                    }

                    AppLovinIntegrationManager.UpdateCurrentVersions(network, pluginRoot);

                    // Refresh UI
                    AssetDatabase.Refresh();
                    EditorUtility.ClearProgressBar();
                }

                GUI.enabled = true;
                GUILayout.Space(5);
            }

            // Custom integration for AdMob where the user can enter the Android and iOS App IDs.
            if (network.Name.Equals("ADMOB_NETWORK") && isInstalled)
            {
                // Custom integration requires Google AdMob adapter version newer than android_19.0.1.0_ios_7.57.0.0.
                if (MaxSdkUtils.CompareUnityMediationVersions(network.CurrentVersions.Unity, "android_19.0.1.0_ios_7.57.0.0") == VersionComparisonResult.Greater)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.Space(20);
                    using (new EditorGUILayout.VerticalScope("box"))
                    {
                        string requiredVersion;
                        string warningMessage;
                        if (isPluginMoved)
                        {
                            requiredVersion = "android_19.6.0.1_ios_7.69.0.0";
                            warningMessage  = "Looks like the MAX plugin has been moved to a different directory. This requires Google adapter version newer than " + requiredVersion + " for auto-export of AdMob App ID to work correctly.";
                        }
                        else
                        {
                            requiredVersion = "android_19.2.0.0_ios_7.61.0.0";
                            warningMessage  = "The current version of AppLovin MAX plugin requires Google adapter version newer than " + requiredVersion + " to enable auto-export of AdMob App ID.";
                        }

                        GUILayout.Space(2);
                        if (MaxSdkUtils.CompareUnityMediationVersions(network.CurrentVersions.Unity, requiredVersion) == VersionComparisonResult.Greater)
                        {
                            AppLovinSettings.Instance.AdMobAndroidAppId = DrawTextField("App ID (Android)", AppLovinSettings.Instance.AdMobAndroidAppId, networkWidthOption);
                            AppLovinSettings.Instance.AdMobIosAppId     = DrawTextField("App ID (iOS)", AppLovinSettings.Instance.AdMobIosAppId, networkWidthOption);
                        }
                        else
                        {
                            EditorGUILayout.HelpBox(warningMessage, MessageType.Warning);
                        }
                    }

                    GUILayout.EndHorizontal();
                }
            }
        }