From 54fd8a20944c4f7e3e025368e837f61e73323576 Mon Sep 17 00:00:00 2001 From: lujiajian <204551278@qq.com> Date: Mon, 20 Jan 2025 14:58:11 +0800 Subject: [PATCH] 1 --- Assets/Scripts/Control_Windows.cs | 62 +++++++++++++++++++ Assets/Scripts/Control_Windows.cs.meta | 11 ++++ Assets/Scripts/语音控制脚本/PlayImage.cs | 29 +++++++++ Assets/Scripts/语音控制脚本/PlayImage.cs.meta | 11 ++++ 4 files changed, 113 insertions(+) create mode 100644 Assets/Scripts/Control_Windows.cs create mode 100644 Assets/Scripts/Control_Windows.cs.meta create mode 100644 Assets/Scripts/语音控制脚本/PlayImage.cs create mode 100644 Assets/Scripts/语音控制脚本/PlayImage.cs.meta 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: