BluetoothHolder.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. /*蓝牙持有者,算是蓝牙模块的管理者,内含调试界面 */
  6. public class BluetoothHolder : MonoBehaviour
  7. {
  8. bool debug = false;
  9. public static BluetoothHolder ins;
  10. public static void Init()
  11. {
  12. if (!BluetoothHolder.ins) {
  13. GameObject bluetoothHolder = Resources.Load<GameObject>("Prefabs/BluetoothHolder");
  14. GameObject.Instantiate(bluetoothHolder);
  15. }
  16. }
  17. void Awake()
  18. {
  19. if (ins)
  20. {
  21. Destroy(this.gameObject);
  22. } else {
  23. ins = this;
  24. DontDestroyOnLoad(this.gameObject);
  25. }
  26. }
  27. void Start() {
  28. if (!debug) {
  29. this.transform.Find("CanvasForOpenDebug").gameObject.SetActive(false);
  30. }
  31. CloseDebug();
  32. // transform.Find("Objects").gameObject.SetActive(true);
  33. }
  34. public void openDebug() {
  35. this.transform.Find("Canvas").gameObject.SetActive(true);
  36. }
  37. public void CloseDebug() {
  38. this.transform.Find("Canvas").gameObject.SetActive(false);
  39. }
  40. public void ClearCalibrateGuide() {
  41. UserSettings.ins.deviceCalibrateGuideFinish = false;
  42. UserSettings.ins.Save();
  43. }
  44. public void SetArrowWeight(InputField inputField) {
  45. string text = inputField.text;
  46. CommonConfig.arrowWeight = float.Parse(text);
  47. }
  48. }