diff --git a/Assets/Scripts/Control_Windows.cs b/Assets/Scripts/Control_Windows.cs new file mode 100644 index 0000000..4a51422 --- /dev/null +++ b/Assets/Scripts/Control_Windows.cs @@ -0,0 +1,62 @@ +using System.Collections; +using System.Collections.Generic; +using TMPro; +using UnityEngine; +using UnityEngine.UI; +/// +/// 控制窗户 +/// +public class Control_Windows : MonoBehaviour +{ + public static Control_Windows Instance; + /// + /// 开/关窗户 + /// + public Button openwindows; + /// + /// 点击的窗户 + /// + 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()); + } + /// + /// 开关窗户 + /// + /// + IEnumerator Openwindow() + { + if (window.GetComponent().GetBlendShapeWeight(0) == 0) + { + openwindows.GetComponentInChildren().text = "关窗"; + for (int i = 1; i < 101; i++) + { + window.GetComponent().SetBlendShapeWeight(0, i); + yield return new WaitForSeconds(0.025f); + } + } + else if (window.GetComponent().GetBlendShapeWeight(0) == 100) + { + openwindows.GetComponentInChildren().text = "开窗"; + for (int i = 100; i >= 0; i--) + { + window.GetComponent().SetBlendShapeWeight(0, i); + yield return new WaitForSeconds(0.025f); + } + } + } +} diff --git a/Assets/Scripts/Control_Windows.cs.meta b/Assets/Scripts/Control_Windows.cs.meta new file mode 100644 index 0000000..3fd064c --- /dev/null +++ b/Assets/Scripts/Control_Windows.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 45c03fd43bc7fb042b6888325efd8f08 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/璇煶鎺у埗鑴氭湰/PlayImage.cs b/Assets/Scripts/璇煶鎺у埗鑴氭湰/PlayImage.cs new file mode 100644 index 0000000..9f8d689 --- /dev/null +++ b/Assets/Scripts/璇煶鎺у埗鑴氭湰/PlayImage.cs @@ -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); + } + } + } +} diff --git a/Assets/Scripts/璇煶鎺у埗鑴氭湰/PlayImage.cs.meta b/Assets/Scripts/璇煶鎺у埗鑴氭湰/PlayImage.cs.meta new file mode 100644 index 0000000..df7f4aa --- /dev/null +++ b/Assets/Scripts/璇煶鎺у埗鑴氭湰/PlayImage.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d9dfd76d105bb0f4389793ded17fa77e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: