From d421d98669fa8cc48e0b1e066b90cdd80a6bd96b Mon Sep 17 00:00:00 2001 From: Mladen Jablanovic Date: Wed, 5 Feb 2025 11:06:27 +0100 Subject: [PATCH] Use SetDirty to mark the asset for save --- Editor/PhraseProvider.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Editor/PhraseProvider.cs b/Editor/PhraseProvider.cs index 76518d1..521536a 100644 --- a/Editor/PhraseProvider.cs +++ b/Editor/PhraseProvider.cs @@ -70,6 +70,11 @@ public partial class PhraseProvider : ScriptableObject private PhraseClient Client => new PhraseClient(this); + void OnEnable() + { + LocalizationSettings.InitializationOperation.WaitForCompletion(); + } + private string StringsAppHost { get @@ -131,6 +136,7 @@ public IEnumerator FetchProjectsAsync() yield return new WaitForEndOfFrame(); Client.UpdateProjectsList(Projects); + EditorUtility.SetDirty(this); IsLoadingProjects = false; } @@ -151,6 +157,7 @@ public IEnumerator FetchLocalesAsync() Client.UpdateLocalesList(m_selectedProjectId, Locales); LocalizationSettings.InitializationOperation.WaitForCompletion(); LocaleIdsToPull.Clear(); + EditorUtility.SetDirty(this); IsLoadingLocales = false; } @@ -597,7 +604,7 @@ private void ShowLocalLocaleMissingSection() continue; } UnityEngine.Localization.Locale newLocale = UnityEngine.Localization.Locale.CreateLocale(locale.code); - AssetDatabase.CreateAsset(newLocale, $"{pathToSave}/{newLocale.ToString()}.asset"); + AssetDatabase.CreateAsset(newLocale, $"{pathToSave}/{newLocale}.asset"); count++; } LocalizationSettings.InitializationOperation.WaitForCompletion(); @@ -801,6 +808,7 @@ private void ShowPushSection() phraseProvider.LocaleIdsToPush.Clear(); phraseProvider.LocaleIdsToPush.AddRange(filteredLocales.Select(l => l.Identifier.Code)); selectedAllLocalesToPush = true; + EditorUtility.SetDirty(target); } } else @@ -809,6 +817,7 @@ private void ShowPushSection() { phraseProvider.LocaleIdsToPush.Clear(); selectedAllLocalesToPush = false; + EditorUtility.SetDirty(target); } } @@ -828,6 +837,7 @@ private void ShowPushSection() selectedAllLocalesToPush = false; phraseProvider.LocaleIdsToPush.Remove(locale.Identifier.Code); } + EditorUtility.SetDirty(target); } } } @@ -859,6 +869,7 @@ private void ShowPullSection() phraseProvider.LocaleIdsToPull.Clear(); phraseProvider.LocaleIdsToPull.AddRange(phraseProvider.AvailableLocalesLocally().Select(l => l.id)); selectedAllLocalesToPull = true; + EditorUtility.SetDirty(target); } } else @@ -867,6 +878,7 @@ private void ShowPullSection() { phraseProvider.LocaleIdsToPull.Clear(); selectedAllLocalesToPull = false; + EditorUtility.SetDirty(target); } } @@ -885,6 +897,7 @@ private void ShowPullSection() selectedAllLocalesToPull = false; phraseProvider.LocaleIdsToPull.Remove(locale.id); } + EditorUtility.SetDirty(target); } } EditorGUI.indentLevel--;