TestFile.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class TestFile : MonoBehaviour
  6. {
  7. public bool isInit;
  8. public Text backt;
  9. public Text backfinalt;
  10. public Text myt;
  11. public InputField inputField;
  12. void Start()
  13. {
  14. YiYanBack _setAndrodCallback = new YiYanBack();
  15. UnityToJava.initSpeek(_setAndrodCallback);
  16. isInit = true;
  17. }
  18. private void OnApplicationPause(bool pause)
  19. {
  20. if(isInit)
  21. {
  22. if(pause)
  23. {
  24. UnityToJava.yiYanClass.CallStatic("onPauseJava");
  25. }
  26. else
  27. {
  28. UnityToJava.yiYanClass.CallStatic("onResumeJava");
  29. }
  30. }
  31. }
  32. public void StopSpeek()
  33. {
  34. UnityToJava.yiYanClass.CallStatic("StopSpeek");
  35. }
  36. public void audio1()
  37. {
  38. UnityToJava.yiYanClass.CallStatic("next_audio");
  39. }
  40. public void audio2()
  41. {
  42. UnityToJava.yiYanClass.CallStatic("previous_audio");
  43. }
  44. public void audio3()
  45. {
  46. UnityToJava.yiYanClass.CallStatic("default_audio");
  47. }
  48. public void StartSpeek()
  49. {
  50. UnityToJava.yiYanClass.CallStatic("StartSpeek");
  51. }
  52. private void OnDestroy()
  53. {
  54. UnityToJava.yiYanClass.CallStatic("onDestroyJava");
  55. }
  56. private void Update()
  57. {
  58. if (YiYanBack.BackTextlist.Count > 0)
  59. {
  60. backt.text = YiYanBack.BackTextlist.Dequeue();
  61. }
  62. if (YiYanBack.BackFINALTextlist.Count > 0)
  63. {
  64. backfinalt.text = YiYanBack.BackFINALTextlist.Dequeue();
  65. send(backfinalt.text);
  66. inputField.text = myt.text;
  67. }
  68. if (YiYanBack.MyTextlist.Count > 0)
  69. {
  70. myt.text = YiYanBack.MyTextlist.Dequeue();
  71. inputField.text = myt.text;
  72. }
  73. }
  74. public void send(string str)
  75. {
  76. UnityToJava.yiYanClass.CallStatic("SendText",str);
  77. }
  78. public void sendText()
  79. {
  80. send(inputField.text);
  81. }
  82. }