This commit is contained in:
parent
4cc2046b57
commit
54fd8a2094
|
@ -0,0 +1,62 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using TMPro;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
/// <summary>
|
||||||
|
/// 控制窗户
|
||||||
|
/// </summary>
|
||||||
|
public class Control_Windows : MonoBehaviour
|
||||||
|
{
|
||||||
|
public static Control_Windows Instance;
|
||||||
|
/// <summary>
|
||||||
|
/// 开/关窗户
|
||||||
|
/// </summary>
|
||||||
|
public Button openwindows;
|
||||||
|
/// <summary>
|
||||||
|
/// 点击的窗户
|
||||||
|
/// </summary>
|
||||||
|
public Transform window;
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
Instance = this;
|
||||||
|
}
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
openwindows.onClick.AddListener(() => { Openwindows(); });
|
||||||
|
}
|
||||||
|
// Update is called once per frame
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
public void Openwindows()
|
||||||
|
{
|
||||||
|
StartCoroutine(Openwindow());
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 开关窗户
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
IEnumerator Openwindow()
|
||||||
|
{
|
||||||
|
if (window.GetComponent<SkinnedMeshRenderer>().GetBlendShapeWeight(0) == 0)
|
||||||
|
{
|
||||||
|
openwindows.GetComponentInChildren<TextMeshProUGUI>().text = "关窗";
|
||||||
|
for (int i = 1; i < 101; i++)
|
||||||
|
{
|
||||||
|
window.GetComponent<SkinnedMeshRenderer>().SetBlendShapeWeight(0, i);
|
||||||
|
yield return new WaitForSeconds(0.025f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (window.GetComponent<SkinnedMeshRenderer>().GetBlendShapeWeight(0) == 100)
|
||||||
|
{
|
||||||
|
openwindows.GetComponentInChildren<TextMeshProUGUI>().text = "开窗";
|
||||||
|
for (int i = 100; i >= 0; i--)
|
||||||
|
{
|
||||||
|
window.GetComponent<SkinnedMeshRenderer>().SetBlendShapeWeight(0, i);
|
||||||
|
yield return new WaitForSeconds(0.025f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 45c03fd43bc7fb042b6888325efd8f08
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,29 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
public class PlayImage : MonoBehaviour
|
||||||
|
{
|
||||||
|
public Sprite[] sprites; // 存储序列帧动画的所有帧
|
||||||
|
public float framesPerSecond = 10.0f; // 每秒播放的帧数
|
||||||
|
public Image image;
|
||||||
|
|
||||||
|
// Start is called before the first frame update
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
StartCoroutine(PlaySprites());
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerator PlaySprites()
|
||||||
|
{
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < sprites.Length; i++)
|
||||||
|
{
|
||||||
|
image.sprite = sprites[i];
|
||||||
|
yield return new WaitForSeconds(1f / framesPerSecond);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d9dfd76d105bb0f4389793ded17fa77e
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Loading…
Reference in New Issue