diff --git a/Assets/Scripts/UIScripts/Teacher/SubjectEditorBase.cs b/Assets/Scripts/UIScripts/Teacher/SubjectEditorBase.cs index c7127f7..ae67528 100644 --- a/Assets/Scripts/UIScripts/Teacher/SubjectEditorBase.cs +++ b/Assets/Scripts/UIScripts/Teacher/SubjectEditorBase.cs @@ -16,6 +16,8 @@ public class SubjectEditorBase : BasePanel public InputField input_TaskIntr; public InputField input_FileIntr; + private string subNameKey; + public SubjectEditorBase(string panelName) : base(new UIType(panelName)) { } @@ -41,6 +43,24 @@ public class SubjectEditorBase : BasePanel dropdown_Terrain.onValueChanged.AddListener(TerrainChange); button_Save?.onClick.AddListener(SaveFile); button_finish?.onClick.AddListener(FinishEditor); + + LocalizationManager.LanguageChanged += OnLanguageChanged; + } + + private void OnLanguageChanged() + { + if (subName != null && !string.IsNullOrEmpty(subNameKey)) + subName.text = LocalizationManager.Get(subNameKey); + // Refresh dropdown options with localized terrain names + if (dropdown_Terrain != null) + { + string[] terrainNames = DBManager.Instance.GetABNames(ABType.地形); + for (int i = 0; i < terrainNames.Length && i < dropdown_Terrain.options.Count; i++) + { + dropdown_Terrain.options[i].text = LocalizationManager.Get(terrainNames[i]); + } + dropdown_Terrain.RefreshShownValue(); + } } @@ -61,7 +81,8 @@ public class SubjectEditorBase : BasePanel public void SetSubName(string subNameStr) { - subName.text = subNameStr; + subNameKey = subNameStr; + subName.text = LocalizationManager.Get(subNameStr); } async void TerrainChange(int terrainIndex) @@ -78,6 +99,7 @@ public class SubjectEditorBase : BasePanel public override void OnDestroy(bool isDestroy = false) { base.OnDestroy(isDestroy); + LocalizationManager.LanguageChanged -= OnLanguageChanged; input_TaskIntr.text = ""; input_FileIntr.text = ""; }