using System.Collections; using System.Collections.Generic; using TMPro; using UnityEngine; using UnityEngine.UI; /// /// 控制窗户 /// public class Control_Windows : MonoBehaviour { public static Control_Windows Instance; /// /// 开/关窗户 /// //public Button openwindows; /// /// 点击的窗户 /// public Transform window; public Toggle open; public Toggle close; private void Awake() { Instance = this; } void Start() { //openwindows.onClick.AddListener(() => { Openwindows(); }); } // Update is called once per frame void Update() { } public void Openwindows() { StartCoroutine(Openwindow()); } /// /// 开关窗户 /// /// IEnumerator Openwindow() { if (window.GetComponent().GetBlendShapeWeight(0) == 0) { close.isOn = false; //openwindows.GetComponentInChildren().text = "关窗"; for (int i = 1; i < 101; i++) { window.GetComponent().SetBlendShapeWeight(0, i); yield return new WaitForSeconds(0.025f); } } else if (window.GetComponent().GetBlendShapeWeight(0) == 100) { open.isOn = false; //openwindows.GetComponentInChildren().text = "开窗"; for (int i = 100; i >= 0; i--) { window.GetComponent().SetBlendShapeWeight(0, i); yield return new WaitForSeconds(0.025f); } } } }