| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- /// <summary>
- /// 用于单机直连设备的设置操作
- /// </summary>
- public class DevicesHolder : MonoBehaviour
- {
- public static DevicesHolder ins;
- public static void Init()
- {
- if (!BluetoothHolder.ins)
- {
- GameObject devicesHolder = Resources.Load<GameObject>("Prefabs/DevicesHolder");
- Instantiate(devicesHolder);
- }
- }
- void Awake()
- {
- if (ins)
- {
- Destroy(this.gameObject);
- }
- else
- {
- ins = this;
- DontDestroyOnLoad(this.gameObject);
- }
- }
- // Start is called before the first frame update
- void Start()
- {
-
- }
- /// <summary>
- /// 目前应该只使用红外设备,就是 HOUYIPRO,ARTEMISPRO,Gun
- /// </summary>
- /// <param name="deviceType"></param>
- public void SwitchDeviceByType(AimDeviceType deviceType) {
- //1.默认选择第一个玩家(这里沿用了之前的设置信息代码,和蓝牙无关)
- BluetoothAim.ins.setBLEPlayer(BluetoothPlayer.FIRST_PLAYER);
- Debug.Log("[DevicesHolder]当前选择的操作用户:" + BluetoothAim.ins.getBLEPlayer());
- AimHandler.ins.SetAimDeviceSelectIndex(0);
- //2.切换设备类型
- AimHandler.ins.onCreateTempAimDeviceInfo();
- switch (deviceType)
- {
- case AimDeviceType.HOUYI:
- case AimDeviceType.HOUYI2:
- case AimDeviceType.ARTEMIS:
- case AimDeviceType.HOUYIPRO:
- case AimDeviceType.Gun:
- case AimDeviceType.ARTEMISPRO:
- case AimDeviceType.PistolM17:
- case AimDeviceType.RifleM416:
- AimHandler.ins.SetTempAimDeviceType(deviceType);
- break;
- }
- Debug.Log("[DevicesHolder] SwitchDeviceByType deviceType :" + deviceType);
- //3.连接设备时候操作
- //连接重新初始化
- //进行重新初始化的时候。重置一下对应的mac
- AimHandler.ins.onCreateAimDeviceInfoById();
- AimHandler.ins.SetAimDeviceType(AimHandler.ins.tempAimDeviceInfo.type);
- AimHandler.ins.ResetAimDeviceMac();
- Debug.Log("[DevicesHolder]重新初始化时候 bInitMac :" + AimHandler.ins.aimDeviceInfo.bInitMac);
- //切换 GlobalData.MyDeviceMode
- BluetoothAim.ins.SetMainConnectDeviceType();
- }
- // Update is called once per frame
- //void Update()
- //{
-
- //}
- }
|