| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 | 
							- using System;
 
- using System.Collections;
 
- using System.Collections.Generic;
 
- using UnityEngine;
 
- public class BluetoothDispatcher : MonoBehaviour
 
- {
 
-     public static System.Action<byte[]> aim;
 
-     public static System.Action<byte[]> shoot;
 
-     void Start()
 
-     {
 
-         BluetoothClient.onDataReceived = Dispatch;
 
-     }
 
-     void Dispatch(byte sign, byte[] data)
 
-     {
 
-         if (!IsWindows()) return;
 
-         string logStr = sign + ", LEN " + data.Length;
 
-         logStr +=  ", Bytes " + String.Join(",", data);
 
-         Debug.Log(logStr);
 
-         if (sign == 0 && aim != null)
 
-         {
 
-             aim(data);
 
-         } 
 
-         else if (sign == 1 && shoot != null)
 
-         {
 
-             shoot(data);
 
-         }
 
-     }
 
-     int platformID = -1;
 
-     void SetPlatformID() 
 
-     {
 
-         if (Application.platform == RuntimePlatform.WindowsEditor) platformID = 1;
 
-         else platformID = 2;
 
-     }
 
-     bool IsWindows() 
 
-     {
 
-         if (platformID == -1) SetPlatformID();
 
-         return platformID == 1;
 
-     }
 
- }
 
 
  |