/// <summary> /// Draws AppLovin MAX plugin details. /// </summary> private void DrawPluginDetails() { var appLovinMax = pluginData.AppLovinMax; // Check if a newer version is available to enable the upgrade button. var upgradeButtonEnabled = appLovinMax.CurrentToLatestVersionComparisonResult == VersionComparisonResult.Lesser; GUILayout.BeginHorizontal(); GUILayout.Space(10); using (new EditorGUILayout.VerticalScope("box")) { // Draw plugin version details DrawHeaders("Platform", false); DrawPluginDetailRow("Unity 3D", appLovinMax.CurrentVersions.Unity, appLovinMax.LatestVersions.Unity); DrawPluginDetailRow("Android", appLovinMax.CurrentVersions.Android, appLovinMax.LatestVersions.Android); DrawPluginDetailRow("iOS", appLovinMax.CurrentVersions.Ios, appLovinMax.LatestVersions.Ios); // BeginHorizontal combined with FlexibleSpace makes sure that the button is centered horizontally. GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUI.enabled = upgradeButtonEnabled; if (GUILayout.Button(new GUIContent("Upgrade"), fieldWidth)) { AppLovinEditorCoroutine.StartCoroutine(AppLovinIntegrationManager.Instance.DownloadPlugin(appLovinMax)); } GUI.enabled = true; GUILayout.Space(5); GUILayout.EndHorizontal(); GUILayout.Space(5); } GUILayout.Space(5); GUILayout.EndHorizontal(); }
/// <summary> /// Checks if a new version of the plugin is available and prompts the user to update if one is available. /// </summary> public static void Update() { var now = (int)(DateTime.UtcNow - EpochTime).TotalSeconds; if (EditorPrefs.HasKey(KeyLastUpdateCheckTime)) { var elapsedTime = now - EditorPrefs.GetInt(KeyLastUpdateCheckTime); // Check if we have checked for a new version in the last 24 hrs and skip update if we have. if (elapsedTime < SecondsInADay) { return; } } // Update last checked time. EditorPrefs.SetInt(KeyLastUpdateCheckTime, now); // Load the plugin data AppLovinEditorCoroutine.StartCoroutine(AppLovinIntegrationManager.Instance.LoadPluginData(data => { if (data == null) { return; } ShowPluginUpdateDialogIfNeeded(data); ShowNetworkAdaptersUpdateDialogIfNeeded(data); })); }
/// <summary> /// Creates and starts a coroutine. /// </summary> /// <param name="enumerator">The coroutine to be started</param> /// <returns>The coroutine that has been started.</returns> public static AppLovinEditorCoroutine StartCoroutine(IEnumerator enumerator) { var coroutine = new AppLovinEditorCoroutine(enumerator); coroutine.Start(); return(coroutine); }
/// <summary> /// Checks if a new version of the plugin is available and prompts the user to update if one is available. /// </summary> public static void Update() { // Check if publisher has disabled auto update. if (!EditorPrefs.GetBool(KeyAutoUpdateEnabled, true)) { return; } var now = (int)(DateTime.UtcNow - EpochTime).TotalSeconds; if (EditorPrefs.HasKey(KeyLastUpdateCheckTime)) { var elapsedTime = now - EditorPrefs.GetInt(KeyLastUpdateCheckTime); // Check if we have checked for a new version in the last 24 hrs and skip update if we have. if (elapsedTime < SecondsInADay) { return; } } // Update last checked time. EditorPrefs.SetInt(KeyLastUpdateCheckTime, now); // Load the plugin data AppLovinEditorCoroutine.StartCoroutine(AppLovinIntegrationManager.Instance.LoadPluginData(data => { // Check if the current and latest version are the same. If so, skip update. if (data == null || data.AppLovinMax.LatestVersions.Equals(data.AppLovinMax.CurrentVersions)) { return; } // A new version of the plugin is available. Show a dialog to the publisher. var option = EditorUtility.DisplayDialogComplex( "AppLovin MAX Plugin Update", "A new version of AppLovin MAX plugin is available for download. Update now?", "Download", "Not Now", "Don't Ask Again"); if (option == 0) // Download { Debug.Log("[AppLovin MAX] Downloading plugin..."); AppLovinIntegrationManager.downloadPluginProgressCallback = AppLovinIntegrationManagerWindow.OnDownloadPluginProgress; AppLovinEditorCoroutine.StartCoroutine(AppLovinIntegrationManager.Instance.DownloadPlugin(data.AppLovinMax)); } else if (option == 1) // Not Now { // Do nothing Debug.Log("[AppLovin MAX] Update postponed."); } else if (option == 2) // Don't Ask Again { Debug.Log("[AppLovin MAX] Auto Update disabled. You can enable it again from the AppLovin Integration Manager"); EditorPrefs.SetBool(KeyAutoUpdateEnabled, false); } })); }
private void OnDisable() { if (loadDataCoroutine != null) { loadDataCoroutine.Stop(); loadDataCoroutine = null; } AppLovinIntegrationManager.Instance.CancelDownload(); EditorUtility.ClearProgressBar(); // Saves the AppLovinSettings object if it has been changed. AssetDatabase.SaveAssets(); }
/// <summary> /// Loads the plugin data to be displayed by this window. /// </summary> private void Load() { loadDataCoroutine = AppLovinEditorCoroutine.StartCoroutine(AppLovinIntegrationManager.Instance.LoadPluginData(data => { if (data == null) { pluginDataLoadFailed = true; } else { pluginData = data; pluginDataLoadFailed = false; } CalculateFieldWidth(); Repaint(); })); }
private static void ShowPluginUpdateDialogIfNeeded(PluginData data) { // Check if publisher has disabled auto update. if (!EditorPrefs.GetBool(KeyAutoUpdateEnabled, true)) { return; } // Check if the current and latest version are the same or if the publisher is on a newer version (on beta). If so, skip update. var comparison = data.AppLovinMax.CurrentToLatestVersionComparisonResult; if (comparison == MaxSdkUtils.VersionComparisonResult.Equal || comparison == MaxSdkUtils.VersionComparisonResult.Greater) { return; } // A new version of the plugin is available. Show a dialog to the publisher. var option = EditorUtility.DisplayDialogComplex( "AppLovin MAX Plugin Update", "A new version of AppLovin MAX plugin is available for download. Update now?", "Download", "Not Now", "Don't Ask Again"); if (option == 0) // Download { Debug.Log("[AppLovin MAX] Downloading plugin..."); AppLovinIntegrationManager.downloadPluginProgressCallback = AppLovinIntegrationManagerWindow.OnDownloadPluginProgress; AppLovinEditorCoroutine.StartCoroutine(AppLovinIntegrationManager.Instance.DownloadPlugin(data.AppLovinMax)); } else if (option == 1) // Not Now { // Do nothing Debug.Log("[AppLovin MAX] Update postponed."); } else if (option == 2) // Don't Ask Again { Debug.Log("[AppLovin MAX] Auto Update disabled. You can enable it again from the AppLovin Integration Manager"); EditorPrefs.SetBool(KeyAutoUpdateEnabled, false); } }
/// <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(); } } }