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;
public Toggle Open;
public Toggle Close;
private void Awake()
{
Instance = this;
}
void Start()
{
//opencurtain.onClick.AddListener(() =>
//{
// Opencurtains();
//});
}
private void Update()
{
//如果没在播放动画 则可以继续点击按钮
if (curtain != null && !curtain.GetComponent().isPlaying)
{
Open.interactable = true;
Close.interactable = true;
}
}
public void Opencurtains(bool isopen)
{
Open.interactable = false;
Close.interactable = false;
Opencurtain(isopen);
}
///
/// 开关窗帘
///
///
void Opencurtain(bool isopen)
{
if (curtain.GetComponent().GetBlendShapeWeight(0) == 0&& !isopen)
{
curtain.GetComponent().Play("窗帘开");
}
else if (curtain.GetComponent().GetBlendShapeWeight(0) == 100&& isopen)
{
curtain.GetComponent().Play("窗帘关");
}
}
}