1
0

SerialPortUtilityProResponder.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace ToneTuneToolkit.SerialPort
  5. {
  6. public class SerialPortUtilityProResponder : MonoBehaviour
  7. {
  8. public static SerialPortUtilityProResponder Instance;
  9. // ==============================
  10. private void Awake() => Instance = this;
  11. private void Start() => Init();
  12. private void OnDestroy() => Uninit();
  13. // ==============================
  14. private void Init()
  15. {
  16. SerialPortUtilityProManager.OnReceiveMessage += MessageProcessor;
  17. return;
  18. }
  19. private void Uninit()
  20. {
  21. SerialPortUtilityProManager.OnReceiveMessage -= MessageProcessor;
  22. return;
  23. }
  24. // ==============================
  25. // AA 00 09 00 00 BB
  26. // AA 00 09 00 04 BB
  27. /// <summary>
  28. /// 消息翻译器
  29. /// </summary>
  30. /// <param name="value"></param>
  31. private void MessageProcessor(string value)
  32. {
  33. string[] parts = value.Split(" ");
  34. for (int i = 0; i < parts.Length; i++)
  35. {
  36. if (parts[i] == "04")
  37. {
  38. // GameManager.Instance.EnterStage03SerialPort();
  39. // GameManager.Instance.SetShootingGoal(true);
  40. Debug.Log("asdas");
  41. }
  42. }
  43. return;
  44. }
  45. }
  46. }