using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityEngine.SceneManagement; public class DeviceReconnectView : MonoBehaviour { [SerializeField] GameObject btnConnectBow; [SerializeField] GameObject btnConnectArrow; [SerializeField] Button btnClose; static DeviceReconnectView ins; public Action onComplete = null; public static GameObject Show() { // if (SceneManager.GetActiveScene().name != "Game") return null; // try { // GameObject view = Resources.Load("Prefabs/Views/DeviceReconnectView"); // return GameObject.Instantiate(view); // } catch (Exception) {} return null; } void Awake() { if (ins) { Destroy(this.gameObject); } else { ins = this; } } void Start() { InitBtnForConnect(); RenderDeviceNames(); GameMgr.ins.addLockerForGamePause(this); } void OnDestroy() { GameMgr.ins.removeLockerForGamePause(this); } void Update() { UpdateBtnForConnect(); btnClose.interactable = BluetoothStatus.IsAllConnected(); } void RenderDeviceNames() { try { (DeviceInfo bowInfo, DeviceInfo arrowInfo) = DeviceMgr.ins.GetCurrentBowArrowInfo(); this.transform.Find("ShowBow/Text").GetComponent().SetText(bowInfo.config.name); this.transform.Find("ShowArrow/Text").GetComponent().SetText(arrowInfo.config.name); } catch (System.Exception) {} } void InitBtnForConnect() { btnConnectBow.GetComponent