BluetoothStatus.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  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. } else if (status == BluetoothStatusEnum.ConnectFail) {
  17. return (17, Color.red);
  18. }
  19. return (14, Color.white);
  20. }
  21. public static bool IsAllConnected()
  22. {
  23. if (!BluetoothAim.ins) return false;
  24. return BluetoothAim.ins.status == BluetoothStatusEnum.ConnectSuccess;
  25. }
  26. }
  27. public enum BluetoothStatusEnum
  28. {
  29. None,
  30. Connect,
  31. Connecting,
  32. ConnectSuccess,
  33. ConnectFail
  34. }