Browse Source

windows才会接受转发数据调度

lvjincheng 4 years ago
parent
commit
ad7dda2909
1 changed files with 15 additions and 0 deletions
  1. 15 0
      Assets/DebugShoot/BluetoothDispatcher.cs

+ 15 - 0
Assets/DebugShoot/BluetoothDispatcher.cs

@@ -15,6 +15,7 @@ public class BluetoothDispatcher : MonoBehaviour
 
     void Dispatch(byte sign, byte[] data)
     {
+        if (!IsWindows()) return;
         string logStr = sign + ", LEN " + data.Length;
         logStr +=  ", Bytes " + String.Join(",", data);
         Debug.Log(logStr);
@@ -27,4 +28,18 @@ public class BluetoothDispatcher : MonoBehaviour
             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;
+    }
 }