diff --git a/Assets/RedBlueGames/MulliganRenamer/Editor/GUI/MulliganUserPreferencesWindow.cs b/Assets/RedBlueGames/MulliganRenamer/Editor/GUI/MulliganUserPreferencesWindow.cs index 7ede9a0..2e232ef 100644 --- a/Assets/RedBlueGames/MulliganRenamer/Editor/GUI/MulliganUserPreferencesWindow.cs +++ b/Assets/RedBlueGames/MulliganRenamer/Editor/GUI/MulliganUserPreferencesWindow.cs @@ -91,6 +91,7 @@ public static void DrawPreferences(MulliganUserPreferences preferences, Language var newLanguage = DrawLanguageDropdown(LocalizationManager.Instance.CurrentLanguage); if (newLanguage != LocalizationManager.Instance.CurrentLanguage) { + preferences.CurrentLanguageKey = newLanguage.Key; LocalizationManager.Instance.ChangeLanguage(newLanguage.Key); } diff --git a/Assets/RedBlueGames/MulliganRenamer/Editor/Localization/LocalizationManager.cs b/Assets/RedBlueGames/MulliganRenamer/Editor/Localization/LocalizationManager.cs index 37f7eaf..a405d95 100644 --- a/Assets/RedBlueGames/MulliganRenamer/Editor/Localization/LocalizationManager.cs +++ b/Assets/RedBlueGames/MulliganRenamer/Editor/Localization/LocalizationManager.cs @@ -38,8 +38,6 @@ public class LocalizationManager { private static LocalizationManager _Instance; - private const string LanguagePrefKey = "RedBlueGames.MulliganRenamer.Locale"; - private const string LanguageFoldername = "MulliganLanguages"; public event System.Action LanguageChanged; @@ -111,7 +109,8 @@ public static List LoadAllLanguages() public void Initialize() { this.CacheAllLanguages(); - this.ChangeLanguage(EditorPrefs.GetString(LanguagePrefKey, "en")); + var preferences = MulliganUserPreferences.LoadOrCreatePreferences(); + this.ChangeLanguage(preferences.CurrentLanguageKey); } /// /// Change the current Locale so that Translations are of the new, specified languages @@ -122,7 +121,6 @@ public void ChangeLanguage(string languageKey) var language = this.allLanguages.FirstOrDefault(x => x.Key == languageKey); if (language != null) { - EditorPrefs.SetString(LanguagePrefKey, languageKey); this.currentLanguage = language; if (this.LanguageChanged != null) diff --git a/Assets/RedBlueGames/MulliganRenamer/Editor/PreferencesAndSettings/MulliganUserPreferences.cs b/Assets/RedBlueGames/MulliganRenamer/Editor/PreferencesAndSettings/MulliganUserPreferences.cs index 18327c7..9ae3cc0 100644 --- a/Assets/RedBlueGames/MulliganRenamer/Editor/PreferencesAndSettings/MulliganUserPreferences.cs +++ b/Assets/RedBlueGames/MulliganRenamer/Editor/PreferencesAndSettings/MulliganUserPreferences.cs @@ -72,6 +72,9 @@ public class MulliganUserPreferences : ISerializationCallbackReceiver [SerializeField] private bool hasInitializedColors; + [SerializeField] + private string currentLanguageKey; + /// /// Gets or Sets the previously used Sequence of Rename Operations /// @@ -232,6 +235,19 @@ public Color DeletionBackgroundColor } } + public string CurrentLanguageKey + { + get + { + return this.currentLanguageKey; + } + + set + { + this.currentLanguageKey = value; + } + } + /// /// Create a new Instance of MulliganUserPreferences /// @@ -401,6 +417,7 @@ private void ResetAllValuesToDefault() this.savedPresets = new List(); + this.currentLanguageKey = "en"; } private void UpgradePreferences() @@ -410,6 +427,9 @@ private void UpgradePreferences() this.ResetColorsToDefault(); this.hasInitializedColors = true; } + + // We moved this value into MulliganUserPrefs so delete it if it exists + EditorPrefs.DeleteKey("RedBlueGames.MulliganRenamer.Locale"); } } }