BluetoothDispatcher.cs 567 B

1234567891011121314151617181920212223242526
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class BluetoothDispatcher : MonoBehaviour
  5. {
  6. public static System.Action<byte[]> aim;
  7. public static System.Action<byte[]> shoot;
  8. void Start()
  9. {
  10. BluetoothClient.onDataReceived = Dispatch;
  11. }
  12. void Dispatch(byte sign, byte[] data)
  13. {
  14. Debug.Log(sign + "---" + data);
  15. if (sign == 0 && aim != null)
  16. {
  17. aim(data);
  18. } else if (sign == 1 && shoot != null)
  19. {
  20. shoot(data);
  21. }
  22. }
  23. }