| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class DebugForDevice : MonoBehaviour
- {
- public static DebugForDevice ins;
- void Awake()
- {
- ins = this;
- }
- public void OnDataReceived(byte[] bytes) {
- if (bytes.Length != 27)
- {
- if (bytes.Length == 2)
- {
- Log("T1", "原始电量", string.Join(",", bytes));
- DeviceBatteryView.ins.RenderBattery(1, bytes[0]);
- return;
- }
- if (bytes.Length >= 3 && bytes[2] == 5)
- {
- long time = bytes[8] + (bytes[7] << 8) + (bytes[6] << 16) + (bytes[5] << 24);
- Log("T2", "原始遮挡", string.Join(",", bytes));
- Log("T3", "遮挡时间", time.ToString());
- try {
- ShootCheck.ins.webSocket.Send(time.ToString());
- } catch (Exception) {}
- }
- return;
- } else {
- Log("T", "原始九轴", string.Join(",", bytes));
- }
- }
- void Log(string nodeName, string title, string text) {
- this.transform.Find(nodeName).GetComponentInChildren<Text>().text = title + ": " + text;
- }
- }
|