LanguageM.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.SceneManagement;
  5. public class LanguageM : MonoBehaviour {
  6. public static bool isChinese = true;
  7. private void Start() {
  8. DontDestroyOnLoad(gameObject);
  9. if (Application.platform == RuntimePlatform.WebGLPlayer) {
  10. } else {
  11. GameObject.Find("FullScreenWarn1").SetActive(false);
  12. GameObject.Find("FullScreenWarn2").SetActive(false);
  13. }
  14. }
  15. public void SetIsChinese(bool value) {
  16. isChinese = value;
  17. SceneManager.LoadScene("SceneMain");
  18. }
  19. private bool isInited = false;
  20. private void Update() {
  21. if (isInited) return;
  22. if (GameObject.Find("TextFire") == null) return;
  23. isInited = true;
  24. Debug.Log("已初始化翻译");
  25. GameObject.Find("TextFire").GetComponent<TMPro.TextMeshProUGUI>().text = isChinese ? "射击" : "Shoot";
  26. GameObject.Find("TextReload").GetComponent<TMPro.TextMeshProUGUI>().text = isChinese ? "装弹" : "Reload";
  27. GameObject.Find("TextDeath").GetComponent<TMPro.TextMeshProUGUI>().text = isChinese ? "寄" : "YOU ARE DEAD";
  28. GameObject.Find("TextWin").GetComponent<TMPro.TextMeshProUGUI>().text = isChinese ? "完" : "The End";
  29. GameObject.Find("TextWin (1)").GetComponent<TMPro.TextMeshProUGUI>().text = isChinese ? "感谢你的游玩" : "Thanks for playing";
  30. GameObject.Find("PanWin1").SetActive(false);
  31. Destroy(gameObject);
  32. }
  33. }