using System.Collections; using System.Collections.Generic; using TMPro; using UnityEngine; using UnityEngine.UI; /// /// 空调控制 /// public class Control_Air : MonoBehaviour { public static Control_Air Instance; /// /// 制冷制热模式材质球 0.制冷 1.制热 /// public List ModelMatarils = new List(); /// /// 制冷按钮 /// public Button Cool; /// /// 制热按钮 /// public Button Warm; /// /// 温度+ /// public Button Add; /// /// 温度- /// public Button Sub; /// /// 温度度数 /// public TextMeshProUGUI temperature; private void Awake() { Instance = this; } void Start() { Cool.onClick.AddListener(() => { temperature.text = "16"; GetComponent().material = ModelMatarils[0]; }); Warm.onClick.AddListener(() => { temperature.text = "26"; GetComponent().material = ModelMatarils[1]; }); Add.onClick.AddListener(() => { if (int.Parse(temperature.text) < 32) { temperature.text = (int.Parse(temperature.text) + 1).ToString(); } }); Sub.onClick.AddListener(() => { if (int.Parse(temperature.text) > 16) { temperature.text = (int.Parse(temperature.text) - 1).ToString(); } }); } void Update() { } }