using UnityEditor; using UnityEngine; namespace Crowdin.Editor.UnityLocalization { using Plugin.Helpers.PluginLocalization; using Plugin.Helpers.UnityLocalization; using Plugin.Models; using Plugin.Operations; using Plugin.Server_API.Helpers; public class PullAssetsTranslationsToUnityTranslation : BasePopupEditor { [MenuItem("Tools/Crowdin/Pull assets translations from Crowdin", false, 102)] public static void OpenExportPopup() { InitPopup( LocalizationHelper.GetLocalStringByKey(LocalKeys.pull_assets_translations_popup_title) ); } private TableSelector tableSelector; protected override void OnEnable() { base.OnEnable(); tableSelector = TableSelector.CreateForAssetTables(); } protected override void OnDisable() { base.OnDisable(); tableSelector?.Dispose(); } private void OnGUI() { if (!isBusy) { tableSelector.DrawLayout(); GUILayout.Space(10); if (GUILayout.Button( LocalizationHelper.GetLocalStringByKey(LocalKeys.pull_assets_translations_popup_title))) { status.Clear(); if (!IsProjectSelected()) { return; } if (!UnityLocalizationHelper.IsHavePluginAssetsTables()) { status.AppendLine(LocalizationHelper.GetLocalStringByKey(LocalKeys.no_asset_tables)); return; } if (SettingsHelper.GetProjectType() is ProjectType.StringBased) { DialogUtility.NoAssetActionsInStringBasedProject(); return; } if (tableSelector.NoTablesAreSelected()) { DialogUtility.NoTablesAreSelected(); return; } tableSelector.SaveSettings(); // Asset pulls have no toggle of their own; they share the string popup's persisted // "preserve entry IDs" setting, same as before this was made an explicit option. var options = new PullOptions( tableSelector.ResolveTables(), BranchId: null, PreserveEntryIds: SettingsHelper.GetToggleStatus_PreserveEntryIdsOnImport()); RunOperation( (progress, cancellationToken) => PullAssets.RunAsync(options, progress, cancellationToken), result => { }); } } OnGUIStatusLabel(); } } }