using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI;//使用 该引用,才能获得 Text 组件。 public class Language : MonoBehaviour { //public bool change = false; public string state = "en"; float m_timer = 0; Button btn; public List texts = new List(); private void Start() { /* texts[0] = GameObject.Find("StartButton").GetComponent(); texts[1] = GameObject.Find("SettingButton").GetComponent(); texts[2] = GameObject.Find("HelpButton").GetComponent(); texts[3] = GameObject.Find("QuitButton").GetComponent();*/ } private void Update() { if (state == "ch") { texts[0].text = "开始游戏"; texts[1].text = "设置"; texts[2].text = "帮助"; texts[3].text = "退出"; } else if (state == "en") { texts[0].text= "StartGame"; texts[1].text= "Setting"; texts[2].text = "Help"; texts[3].text = "Quit"; } } public void changeLanguage() { if (state == "en") state = "ch"; else state = "en"; Debug.Log("你改变了语言!"); Debug.Log(texts[0].text); } }