using System.Collections; using System.Collections.Generic; using UnityEngine; using SmartBowSDK; using UnityEngine.UI; public class NewDemo : MonoBehaviour { [SerializeField] Toggle _DetectingMacToggle1; [SerializeField] Toggle _DetectingMacToggle2; SmartBowHelper smartBowHelper1; SmartBowHelper smartBowHelper2; //数据存储标识 string userTags = "test"; // Start is called before the first frame update void Start() { smartBowHelper1 = SmartBowHelper.NewInstance(); smartBowHelper2 = SmartBowHelper.NewInstance(); Init(smartBowHelper1, GameObject.Find("A").GetComponent()); Init(smartBowHelper2, GameObject.Find("B").GetComponent()); SmartBowLogger.isDebug = true; //BleWinHelper.RegisterTo(this.gameObject); } void Init(SmartBowHelper smartBowHelper, Bow bow) { new SmartBowHandler(smartBowHelper, bow); } int deviceId = 1; public void Connect1() { //默认需要检测mac,bRecreateDeviceInfo:false.如不需要:设置bRecreateDeviceInfo:true; bool bRecreateDeviceInfo = _DetectingMacToggle1.isOn ? false : true; smartBowHelper1.Connect(userTags, deviceId, bRecreateDeviceInfo); } public void ClearDeviceInfo1() { smartBowHelper1.ClearDeviceInfo(userTags, deviceId); } int deviceId2 = 2; public void Connect2() { //默认需要检测mac,bRecreateDeviceInfo:false.如不需要:设置bRecreateDeviceInfo:true; bool bRecreateDeviceInfo = _DetectingMacToggle2.isOn ? false : true; smartBowHelper2.Connect(userTags, deviceId2, bRecreateDeviceInfo); } public void ClearDeviceInfo2() { smartBowHelper2.ClearDeviceInfo(userTags, deviceId2); } public void ClearAllDeviceInfo() { ClearDeviceInfo1(); ClearDeviceInfo2(); } public void getAllDeviceInfo() { AimDeviceInfo aimDeviceInfo1 = smartBowHelper1.GetDeviceInfo(userTags, deviceId); Debug.Log("设备1:" + JsonUtility.ToJson(aimDeviceInfo1)); AimDeviceInfo aimDeviceInfo2 = smartBowHelper2.GetDeviceInfo(userTags, deviceId2); Debug.Log("设备2:" + JsonUtility.ToJson(aimDeviceInfo2)); } }