BluetoothStatus.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  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 (int, Color) GetStatusInfo(BluetoothStatusEnum status)
  9. {
  10. if (status == BluetoothStatusEnum.Connecting) {
  11. //return (15, Color.blue);
  12. return (15,new Color(255f / 255f, 165f / 255f, 0));
  13. } else if (status == BluetoothStatusEnum.ConnectSuccess) {
  14. //return (16, Color.new Color32(255,215,0,0));
  15. // return (16,new Color(255f / 255f, 215f / 255f, 0));
  16. return (16, new Color(255 / 255f, 243 / 255f, 103 / 255f));
  17. } else if (status == BluetoothStatusEnum.ConnectFail) {
  18. return (17, Color.red);
  19. }
  20. return (14, Color.white);
  21. }
  22. public static bool IsAllConnected()
  23. {
  24. if (!BluetoothAim.ins) return false;
  25. return BluetoothAim.ins.status == BluetoothStatusEnum.ConnectSuccess;
  26. }
  27. }
  28. public enum BluetoothStatusEnum
  29. {
  30. None,
  31. Connect,
  32. Connecting,
  33. ConnectSuccess,
  34. ConnectFail
  35. }