using System.Collections; using System.Collections.Generic; using UnityEngine; /// /// 语音指令 /// public enum Voice { /// /// 打开第一个景点 /// OpenSpoitOne = 1, OpenSpoitTwo = 2, OpenSpoitThree = 3, OpenSpoitFour = 4, OpenSpoitFire = 5, /// /// 调高音量 /// ADDAudio = 11, SubAudio = 12, /// /// 返回主菜单 /// Menu = 13, NullVoice = -1 } public class TestVoice : MonoBehaviour { public Transform voiceLocator; public Transform HeadPos; private Voice voice = Voice.NullVoice; /// /// 设置当前模式 /// /// 语音指令 public void SettingVoice(int recognition) { voice = (Voice)recognition; // 首先要获取对应ImageTarget的cube位置 // 判断当前是否为扫图模式 // GameManager.Instance.text3.text = voice.ToString(); switch (voice) { case Voice.OpenSpoitOne: case Voice.OpenSpoitTwo: case Voice.OpenSpoitThree: case Voice.OpenSpoitFour: case Voice.OpenSpoitFire: OpenSceneSpoit((int)voice); break; case Voice.ADDAudio: float addvolume = AudioListener.volume; addvolume += 0.1f; if (addvolume > 1) addvolume = 1; AudioListener.volume = addvolume; GameManager.Instance.text.text = AudioListener.volume.ToString(); break; case Voice.SubAudio: float subvolume = AudioListener.volume; subvolume -= 0.1f; if (subvolume <0) subvolume = 0; AudioListener.volume = subvolume; GameManager.Instance.text.text = AudioListener.volume.ToString(); break; case Voice.Menu: // 返回菜单 break; case Voice.NullVoice: break; default: break; } } public void OpenSceneSpoit( int num) { if (VuforialControl.Instance.state) return; voiceLocator.position = new Vector3(HeadPos.position.x, HeadPos.position.y - 1f, HeadPos.position.z); voiceLocator.rotation = HeadPos.rotation; num--; VuforialControl.Instance.ReplaceSceneSpoit(voiceLocator, num, 0); } }