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