using System.Collections; using System.Collections.Generic; using TMPro; using UnityEngine; using UnityEngine.UI; /// /// 打开窗帘/窗户 /// public class Control_Curtain : MonoBehaviour { public static Control_Curtain Instance; /// /// 开/关窗帘 /// public Button opencurtain; /// /// 点击的窗帘 /// public Transform curtain; private void Awake() { Instance = this; } void Start() { opencurtain.onClick.AddListener(() => { Opencurtains(); }); } public void Opencurtains() { Opencurtain(); } /// /// 开关窗帘 /// /// void Opencurtain() { if (curtain.GetComponent().GetBlendShapeWeight(0) == 0) { opencurtain.GetComponentInChildren().text = "拉开窗帘"; curtain.GetComponent().Play("窗帘开"); } else if (curtain.GetComponent().GetBlendShapeWeight(0) == 100) { opencurtain.GetComponentInChildren().text = "拉起窗帘"; curtain.GetComponent().Play("窗帘关"); } } }