using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; namespace SC.XR.Unity.Module_DetectorSystem { public class Example : MonoBehaviour { public Button chineseBtn; public Button englishBtn; public SCToggleCheckbox3D useSystemLanguageToggle; public Button getSystemLanguageBtn; public Text currentSystemLanguage; public object API_Module_Language { get; private set; } private void Awake() { chineseBtn.onClick.AddListener(OnClickChineseBtn); englishBtn.onClick.AddListener(OnClickEnglishBtn); useSystemLanguageToggle.onValueChanged.AddListener(OnUseSystemLanguageToggleValueChanged); getSystemLanguageBtn.onClick.AddListener(OnClickGetSystemLanguageBtn); } private void Update() { if (Input.GetKeyDown(KeyCode.K)) { API_Module_DetectorSystem_Notice.SetNotice("The device position is NAN", "Please Reboot recovery", NoticeType.Warning, 0.8f, AlignmentType.Center, FollowType.False); API_Module_DetectorSystem_Notice.Show(1.5f); } } private void OnDestroy() { chineseBtn.onClick.RemoveListener(OnClickChineseBtn); englishBtn.onClick.RemoveListener(OnClickEnglishBtn); useSystemLanguageToggle.onValueChanged.RemoveListener(OnUseSystemLanguageToggleValueChanged); getSystemLanguageBtn.onClick.RemoveListener(OnClickGetSystemLanguageBtn); } public void OnClickChineseBtn() { SCBatteryDetector.getInstance.ChangeLanguage(DeviveBatteryLanguageEnum.Chinese); chineseBtn.GetComponentInChildren().text = "切换中文"; englishBtn.GetComponentInChildren().text = "切换英文"; useSystemLanguageToggle.GetComponentInChildren().text = "使用系统语言"; } public void OnClickEnglishBtn() { SCBatteryDetector.getInstance.ChangeLanguage(DeviveBatteryLanguageEnum.English); chineseBtn.GetComponentInChildren().text = "Change Chinese"; englishBtn.GetComponentInChildren().text = "Change English"; useSystemLanguageToggle.GetComponentInChildren().text = "Use System Language"; } public void OnUseSystemLanguageToggleValueChanged(bool value) { SCBatteryDetector.getInstance.useSystemLanguage = value; } public void OnClickGetSystemLanguageBtn() { switch (API_Module_DetectorSystem_Language.GetSystemLanguage()) { case SCLanguageEnum.ChineseSimplified: case SCLanguageEnum.ChineseTraditional: getSystemLanguageBtn.GetComponentInChildren().text = "获取当前系统语言"; currentSystemLanguage.text = "当前系统语言:中文"; break; case SCLanguageEnum.English: getSystemLanguageBtn.GetComponentInChildren().text = "Get Current System Language"; currentSystemLanguage.text = "Current System Language : English"; break; } } } }