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(() =>
{
StartCoroutine(Opencurtain());
});
}
///
/// 开关窗帘
///
///
IEnumerator Opencurtain()
{
if (curtain.GetComponent().GetBlendShapeWeight(0) == 0)
{
opencurtain.GetComponentInChildren().text = "拉开窗帘";
for (int i = 1; i < 101; i++)
{
curtain.GetComponent().SetBlendShapeWeight(0, i);
yield return new WaitForSeconds(0.025f);
}
}
else if (curtain.GetComponent().GetBlendShapeWeight(0) == 100)
{
opencurtain.GetComponentInChildren().text = "拉起窗帘";
for (int i = 100; i >= 0; i--)
{
curtain.GetComponent().SetBlendShapeWeight(0, i);
yield return new WaitForSeconds(0.025f);
}
}
}
}