12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- 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>().text = "切换中文";
- englishBtn.GetComponentInChildren<Text>().text = "切换英文";
- useSystemLanguageToggle.GetComponentInChildren<TextMesh>().text = "使用系统语言";
- }
- public void OnClickEnglishBtn()
- {
- SCBatteryDetector.getInstance.ChangeLanguage(DeviveBatteryLanguageEnum.English);
- chineseBtn.GetComponentInChildren<Text>().text = "Change Chinese";
- englishBtn.GetComponentInChildren<Text>().text = "Change English";
- useSystemLanguageToggle.GetComponentInChildren<TextMesh>().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>().text = "获取当前系统语言";
- currentSystemLanguage.text = "当前系统语言:中文";
- break;
- case SCLanguageEnum.English:
- getSystemLanguageBtn.GetComponentInChildren<Text>().text = "Get Current System Language";
- currentSystemLanguage.text = "Current System Language : English";
- break;
- }
- }
- }
- }
|