TestVoice.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. /// <summary>
  5. /// 语音指令
  6. /// </summary>
  7. public enum Voice
  8. {
  9. /// <summary>
  10. /// 全局
  11. /// </summary>
  12. Global,
  13. /// <summary>
  14. /// 临境
  15. /// </summary>
  16. Immersed,
  17. /// <summary>
  18. /// 协同
  19. /// </summary>
  20. Synergy,
  21. NullVoice =-1
  22. }
  23. public class TestVoice : MonoBehaviour
  24. {
  25. /// <summary>
  26. /// 设置当前模式
  27. /// </summary>
  28. /// <param name="voice"> 语音指令</param>
  29. public void SettingVoice(int recognition)
  30. {
  31. Voice voice = Voice.NullVoice;
  32. switch (recognition)
  33. {
  34. case 2:
  35. voice = Voice.Immersed;
  36. break;
  37. case 3:
  38. voice = Voice.Synergy;
  39. break;
  40. case 4:
  41. voice = Voice.NullVoice;
  42. break;
  43. case 1:
  44. case 5:
  45. case 6:
  46. voice = Voice.Global;
  47. break;
  48. default:
  49. break;
  50. }
  51. switch (voice)
  52. {
  53. case Voice.Global:
  54. GameManager.instacne.UserClick("OpenScence3");
  55. break;
  56. case Voice.Immersed:
  57. GameManager.instacne.UserClick("OpenScence4");
  58. break;
  59. case Voice.Synergy:
  60. GameManager.instacne.UserClick("OpenScence5");
  61. break;
  62. case Voice.NullVoice:
  63. Debug.Log(" Invalid Voice ");
  64. break;
  65. default:
  66. break;
  67. }
  68. }
  69. }