ict.shenzhi/Assets/ZHYscrip/scrip/IDESettingFuntion.cs

86 lines
2.6 KiB
C#

using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class IDESettingFuntion : MonoBehaviour
{
/// <summary>
/// 储存按钮的list
/// </summary>
public List<GameObject> button;
/// <summary>
/// 路径的list
/// </summary>
public List<GameObject> path;
/// <summary>
/// 开始按钮的list
/// </summary>
public List<GameObject> startButton;
/// <summary>
/// 公开一个脚本
/// </summary>
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<UnityEngine.UI.Button>().onClick.AddListener(Reset);
button[0].GetComponent<UnityEngine.UI.Button>().onClick.AddListener(delegate () { this.buttonclick(0); });
break;
case 1:
button[1].GetComponent<UnityEngine.UI.Button>().onClick.AddListener(Reset);
button[1].GetComponent<UnityEngine.UI.Button>().onClick.AddListener(delegate () { this.buttonclick(1); });
break;
case 2:
button[2].GetComponent<UnityEngine.UI.Button>().onClick.AddListener(Reset);
button[2].GetComponent<UnityEngine.UI.Button>().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<Image>().color = new Vector4(120f / 255f, 60f / 255f, 1f, 0f);
n.transform.GetChild(0).GetComponent<TextMeshProUGUI>().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<Image>().color = new Vector4(120f / 255f, 60f / 255f, 1f, 1f);
button[n].transform.GetChild(0).GetComponent<TextMeshProUGUI>().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";
}
}