73 lines
1.6 KiB
C#
73 lines
1.6 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
/// <summary>
|
|
/// 空调控制
|
|
/// </summary>
|
|
public class Control_Air : MonoBehaviour
|
|
{
|
|
public static Control_Air Instance;
|
|
|
|
/// <summary>
|
|
/// 制冷制热模式材质球 0.制冷 1.制热
|
|
/// </summary>
|
|
public List<Material> ModelMatarils = new List<Material>();
|
|
/// <summary>
|
|
/// 制冷按钮
|
|
/// </summary>
|
|
public Button Cool;
|
|
/// <summary>
|
|
/// 制热按钮
|
|
/// </summary>
|
|
public Button Warm;
|
|
/// <summary>
|
|
/// 温度+
|
|
/// </summary>
|
|
public Button Add;
|
|
/// <summary>
|
|
/// 温度-
|
|
/// </summary>
|
|
public Button Sub;
|
|
/// <summary>
|
|
/// 温度度数
|
|
/// </summary>
|
|
public TextMeshProUGUI temperature;
|
|
private void Awake()
|
|
{
|
|
Instance = this;
|
|
}
|
|
void Start()
|
|
{
|
|
Cool.onClick.AddListener(() =>
|
|
{
|
|
temperature.text = "16";
|
|
GetComponent<MeshRenderer>().material = ModelMatarils[0];
|
|
});
|
|
Warm.onClick.AddListener(() =>
|
|
{
|
|
temperature.text = "26";
|
|
GetComponent<MeshRenderer>().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()
|
|
{
|
|
|
|
}
|
|
}
|