summaryrefslogtreecommitdiff
path: root/GameCode/SettingsLanguage.cs
diff options
context:
space:
mode:
authorchai <215380520@qq.com>2023-11-02 11:51:31 +0800
committerchai <215380520@qq.com>2023-11-02 11:51:31 +0800
commit7f493f682503f5186308de7b8f74b5b49233cfe4 (patch)
tree8a91e2056bc79788ee4735dce88b8d516ba12beb /GameCode/SettingsLanguage.cs
+init
Diffstat (limited to 'GameCode/SettingsLanguage.cs')
-rw-r--r--GameCode/SettingsLanguage.cs32
1 files changed, 32 insertions, 0 deletions
diff --git a/GameCode/SettingsLanguage.cs b/GameCode/SettingsLanguage.cs
new file mode 100644
index 0000000..57173ee
--- /dev/null
+++ b/GameCode/SettingsLanguage.cs
@@ -0,0 +1,32 @@
+using I2.Loc;
+using UnityEngine;
+
+public class SettingsLanguage : MonoBehaviour
+{
+ public EnumSelector selector;
+
+ private void Start()
+ {
+ selector.onChange.AddListener(OnChange);
+ }
+
+ private void OnEnable()
+ {
+ selector.options.Clear();
+ selector.options.AddRange(LocalizationManager.GetAllLanguages());
+ string currentLanguage = LocalizationManager.CurrentLanguage;
+ for (int i = 0; i < selector.options.Count; i++)
+ {
+ if (selector.options[i] == currentLanguage)
+ {
+ selector.SetIndex(i);
+ break;
+ }
+ }
+ }
+
+ private void OnChange()
+ {
+ LocalizationManager.CurrentLanguage = selector.options[selector.Index];
+ }
+}