using System.Collections; using System.Collections.Generic; using TMPro; using UnityEngine; using UnityEngine.UI; public class IDESettingFuntion : MonoBehaviour { /// /// 储存按钮的list /// public List button; /// /// 路径的list /// public List path; /// /// 开始按钮的list /// public List startButton; /// /// 公开一个脚本 /// public clean action; // Start is called before the first frame update void Start() { for (int n = 0; n < button.Count; n++) { switch (n) { case 0: button[0].GetComponent().onClick.AddListener(Reset); button[0].GetComponent().onClick.AddListener(delegate () { this.buttonclick(0); }); break; case 1: button[1].GetComponent().onClick.AddListener(Reset); button[1].GetComponent().onClick.AddListener(delegate () { this.buttonclick(1); }); break; case 2: button[2].GetComponent().onClick.AddListener(Reset); button[2].GetComponent().onClick.AddListener(delegate () { this.buttonclick(2); }); break; } } } // Update is called once per frame void Update() { } private void Reset() { foreach (GameObject n in button) { n.GetComponent().color = new Vector4(120f / 255f, 60f / 255f, 1f, 0f); n.transform.GetChild(0).GetComponent().color = new Vector4(160f/255f, 160f/255f, 160f/255f, 160f/255f); } foreach (GameObject n in path) { n.SetActive(false); } foreach (GameObject n in startButton) { n.SetActive(false); } } private void buttonclick(int n) { button[n].GetComponent().color = new Vector4(120f / 255f, 60f / 255f, 1f, 1f); button[n].transform.GetChild(0).GetComponent().color = new Vector4(1f, 1f, 1f, 1f); path[n].SetActive(true); startButton[n].SetActive(true); if (n == 0) action.nowChoose = "Python"; if (n == 1) action.nowChoose = "Java"; if (n == 2) action.nowChoose = "C"; } }