BluetoothStatus.cs 1009 B

12345678910111213141516171819202122232425262728293031323334
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. /* 蓝牙状态信息获取接口 */
  5. public class BluetoothStatus
  6. {
  7. // return textID, Color
  8. public static (string, Color) GetStatusInfo(BluetoothStatusEnum status)
  9. {
  10. if (status == BluetoothStatusEnum.Connecting) {
  11. return ("正在连接", new Color(255f / 255f, 165f / 255f, 0));
  12. } else if (status == BluetoothStatusEnum.ConnectSuccess) {
  13. return ("连接成功", new Color(255 / 255f, 243 / 255f, 103 / 255f));
  14. } else if (status == BluetoothStatusEnum.ConnectFail) {
  15. return ("连接断开", Color.red);
  16. }
  17. return ("连接模块", Color.white);
  18. }
  19. public static bool IsAllConnected()
  20. {
  21. if (!BluetoothAim.ins) return false;
  22. return BluetoothAim.ins.status == BluetoothStatusEnum.ConnectSuccess;
  23. }
  24. }
  25. public enum BluetoothStatusEnum
  26. {
  27. None,
  28. Connect,
  29. Connecting,
  30. ConnectSuccess,
  31. ConnectFail
  32. }