/// <summary> /// Updates the CurrentVersion fields for a given network data object. /// </summary> /// <param name="network">Network for which to update the current versions.</param> /// <param name="mediationPluginParentDirectory">The parent directory of where the mediation adapter plugins are imported to.</param> public static void UpdateCurrentVersions(Network network, string mediationPluginParentDirectory) { var dependencyFilePath = Path.Combine(mediationPluginParentDirectory, network.DependenciesFilePath); var currentVersions = GetCurrentVersions(dependencyFilePath); network.CurrentVersions = currentVersions; // If AppLovin mediation plugin, get the version from MaxSdk and the latest and current version comparison. if (network.Name.Equals("APPLOVIN_NETWORK")) { network.CurrentVersions.Unity = MaxSdk.Version; var unityVersionComparison = MaxSdkUtils.CompareVersions(network.CurrentVersions.Unity, network.LatestVersions.Unity); var androidVersionComparison = MaxSdkUtils.CompareVersions(network.CurrentVersions.Android, network.LatestVersions.Android); var iosVersionComparison = MaxSdkUtils.CompareVersions(network.CurrentVersions.Ios, network.LatestVersions.Ios); // Overall version is same if all the current and latest (from db) versions are same. if (unityVersionComparison == VersionComparisonResult.Equal && androidVersionComparison == VersionComparisonResult.Equal && iosVersionComparison == VersionComparisonResult.Equal) { network.CurrentToLatestVersionComparisonResult = VersionComparisonResult.Equal; } // One of the installed versions is newer than the latest versions which means that the publisher is on a beta version. else if (unityVersionComparison == VersionComparisonResult.Greater || androidVersionComparison == VersionComparisonResult.Greater || iosVersionComparison == VersionComparisonResult.Greater) { network.CurrentToLatestVersionComparisonResult = VersionComparisonResult.Greater; } // We have a new version available if all Android, iOS and Unity has a newer version available in db. else { network.CurrentToLatestVersionComparisonResult = VersionComparisonResult.Lesser; } } // For all other mediation adapters, get the version comparison using their Unity versions. else { // If adapter is indeed installed, compare the current (installed) and the latest (from db) versions, so that we can determine if the publisher is on an older, current or a newer version of the adapter. // If the publisher is on a newer version of the adapter than the db version, that means they are on a beta version. if (!string.IsNullOrEmpty(currentVersions.Unity)) { network.CurrentToLatestVersionComparisonResult = MaxSdkUtils.CompareUnityMediationVersions(currentVersions.Unity, network.LatestVersions.Unity); } if (!string.IsNullOrEmpty(network.CurrentVersions.Unity) && AppLovinAutoUpdater.MinAdapterVersions.ContainsKey(network.Name)) { var comparisonResult = MaxSdkUtils.CompareUnityMediationVersions(network.CurrentVersions.Unity, AppLovinAutoUpdater.MinAdapterVersions[network.Name]); // Requires update if current version is lower than the min required version. network.RequiresUpdate = comparisonResult < 0; } else { // Reset value so that the Integration manager can hide the alert icon once adapter is updated. network.RequiresUpdate = false; } } }
/// <summary> /// Updates the CurrentVersion fields for a given network data object. /// </summary> /// <param name="network">Network for which to update the current versions.</param> public static void UpdateCurrentVersions(Network network) { var dependencyFilePath = Path.Combine(Application.dataPath, network.DependenciesFilePath); var currentVersions = GetCurrentVersions(dependencyFilePath); network.CurrentVersions = currentVersions; // If adapter is indeed installed, compare the current (installed) and the latest (from db) versions, so that we can determine if the publisher is on an older, current or a newer version of the adapter. // If the publisher is on a newer version of the adapter than the db version, that means they are on a beta version. if (!string.IsNullOrEmpty(currentVersions.Unity)) { network.CurrentToLatestVersionComparison = MaxSdkUtils.CompareUnityMediationVersions(currentVersions.Unity, network.LatestVersions.Unity); } // If AppLovin mediation plugin, get the version from MaxSdk. if (network.Name.Equals("APPLOVIN_NETWORK")) { network.CurrentVersions.Unity = MaxSdk.Version; } }
/// <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." }, uninstallButtonStyle); } 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" }, uninstallButtonStyle)) { EditorUtility.DisplayProgressBar("Integration Manager", "Deleting " + network.Name + "...", 0.5f); foreach (var pluginFilePath in network.PluginFilePaths) { FileUtil.DeleteFileOrDirectory(Path.Combine("Assets", pluginFilePath)); } AppLovinIntegrationManager.UpdateCurrentVersions(network); // 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")) { GUILayout.Space(2); if (MaxSdkUtils.CompareUnityMediationVersions(network.CurrentVersions.Unity, "android_19.2.0.0_ios_7.61.0.0") == 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("The current version of AppLovin MAX plugin requires Google adapter version newer than android_19.2.0.0_ios_7.61.0.0 to enable auto-export of AdMob App ID.", MessageType.Warning); } } GUILayout.EndHorizontal(); } } }
/// <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); } if (isInstalled) { // Custom integration for AdMob where the user can enter the Android and iOS App IDs. if (network.Name.Equals("ADMOB_NETWORK")) { // 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(); } } // Snap requires SCAppStoreAppID to be set starting adapter version 2.0.0.0 or newer. Show a text field for the publisher to input the App ID. else if (network.Name.Equals("SNAP_NETWORK") && MaxSdkUtils.CompareVersions(network.CurrentVersions.Ios, AppLovinSettings.SnapAppStoreAppIdMinVersion) != VersionComparisonResult.Lesser) { GUILayout.BeginHorizontal(); GUILayout.Space(20); using (new EditorGUILayout.VerticalScope("box")) { GUILayout.Space(2); GUILayout.BeginHorizontal(); GUILayout.Space(4); EditorGUILayout.LabelField(new GUIContent("App Store App ID (iOS)"), networkWidthOption); GUILayout.Space(4); AppLovinSettings.Instance.SnapAppStoreAppId = EditorGUILayout.IntField(AppLovinSettings.Instance.SnapAppStoreAppId); GUILayout.Space(4); GUILayout.EndHorizontal(); GUILayout.Space(2); } GUILayout.EndHorizontal(); } } }