| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- /* 设备界面 */
- public class DeviceView1 : MonoBehaviour, MenuBackInterface
- {
- GameObject bowOptions;
- [SerializeField] GameObject btnConnectBow;
- void Start()
- {
- PersistenHandler.ins?.menuBackCtr.views.Add(this);
- btnConnectBow.GetComponent<Button>().onClick.AddListener(delegate() {
- BluetoothAim.ins.DoConnect();
- });
- bowOptions = this.transform.Find("ItemInfo/BowOptions").gameObject;
- //初始化弓的校准按钮
- Button[] bowOptionBtns = bowOptions.GetComponentsInChildren<Button>();
- for (int i = 0; i < bowOptionBtns.Length; i++)
- {
- int optionID = i;
- bowOptionBtns[i].onClick.AddListener(delegate() {
- AudioMgr.ins.PlayBtn();
- switch (optionID)
- {
- case 0:
- DeviceCalibrateView.Create(DeviceCalibrateItem.Gyr);
- break;
- case 1:
- DeviceCalibrateView.Create(DeviceCalibrateItem.Mag);
- break;
- }
- });
- }
- }
- void OnDestroy()
- {
- PersistenHandler.ins?.menuBackCtr.views.Remove(this);
- }
- void Update()
- {
- UpdateBtnForConnect();
- }
- BluetoothStatusEnum bowStatus;
- void UpdateBtnForConnect() {
- if (BluetoothAim.ins && bowStatus != BluetoothAim.ins.status) {
- bowStatus = BluetoothAim.ins.status;
- (int textID, Color color) = BluetoothStatus.GetStatusInfo(BluetoothAim.ins.status);
- btnConnectBow.GetComponentInChildren<TextAutoLanguage>().SetText(textID);
- btnConnectBow.GetComponentInChildren<Text>().color = color;
- btnConnectBow.transform.Find("Check").gameObject.SetActive(bowStatus == BluetoothStatusEnum.ConnectSuccess);
- }
- }
- public bool OnMenuBack() {
- Destroy(gameObject);
- return true;
- }
- public void OnClick_Back() {
- AudioMgr.ins.PlayBtn();
- Destroy(this.gameObject);
- }
- }
|