using System.Collections.Generic; using UnityEngine; using ArduinoBluetoothAPI; using System; using System.Text; using UnityEngine.UI; namespace DuckHunter { public class ConnectAdvertising : MonoBehaviour { Button advertisingBtn; Text advertisingText; GameObject connectTip; float speed = 10.0f; Vector3 targetPos = Vector3.zero; private BluetoothHelper helper; private BluetoothHelperCharacteristic characteristicWrite; private BluetoothHelperService bluetoothService; private bool isScanning; private bool isConnecting; private string data; private string tempVector; private string tmp; private string targetDeviceName = "SLAM_Advertiser"; private string deviceName = ""; string targetDeviceService = "0000fff1"; string targetDeviceCharacteristicWrite = "0000ff11"; string targetDeviceCharacteristicNotify = "0000ff11"; private LinkedList devices; public GUIBox gUIBox; void Awake() { GameObject AdVertiserManagerObj = GameObject.Find("AdVertiserManager"); if (AdVertiserManagerObj) { //刷新一次持久化对象的状态 AdVertiserManagerObj.GetComponent().OnUpdateState(); Destroy(gameObject); return; } DontDestroyOnLoad(gameObject); transform.name = "AdVertiserManager"; OnUpdateState(); } public void OnUpdateState() { advertisingBtn = GameObject.Find("GameManager/GameUI/ConnectButton").GetComponent