123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- /// <summary>
- /// 语音指令
- /// </summary>
- public enum Voice
- {
- /// <summary>
- /// 打开第一个景点
- /// </summary>
- OpenSpoitOne = 1,
- OpenSpoitTwo = 2,
- OpenSpoitThree = 3,
- OpenSpoitFour = 4,
- OpenSpoitFire = 5,
- /// <summary>
- /// 调高音量
- /// </summary>
- ADDAudio = 11,
- SubAudio = 12,
- /// <summary>
- /// 返回主菜单
- /// </summary>
- Menu = 13,
- NullVoice = -1
- }
- public class TestVoice : MonoBehaviour
- {
- public Transform voiceLocator;
- public Transform HeadPos;
- private Voice voice = Voice.NullVoice;
- /// <summary>
- /// 设置当前模式
- /// </summary>
- /// <param name="voice"> 语音指令</param>
- 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);
- }
- }
|