소스 검색

windows才会接受转发数据调度

lvjincheng 4 년 전
부모
커밋
ad7dda2909
1개의 변경된 파일15개의 추가작업 그리고 0개의 파일을 삭제
  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;
+    }
 }