SimpleDemo.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using SmartBowSDK;
  5. using UnityEngine.UI;
  6. public class SimpleDemo : MonoBehaviour
  7. {
  8. [SerializeField] Toggle _DetectingMacToggle1;
  9. SmartBowHelper smartBowHelper1;
  10. //数据存储标识
  11. string userTags = "test";
  12. // Start is called before the first frame update
  13. void Start()
  14. {
  15. smartBowHelper1 = SmartBowHelper.NewInstance();
  16. Init(smartBowHelper1, GameObject.Find("A").GetComponent<Bow>());
  17. SmartBowLogger.isDebug = true;
  18. }
  19. void Init(SmartBowHelper smartBowHelper, Bow bow)
  20. {
  21. new SmartBowHandler(smartBowHelper, bow);
  22. }
  23. int deviceId = 1;
  24. public void Connect1()
  25. {
  26. //默认需要检测mac,bRecreateDeviceInfo:false.如不需要:设置bRecreateDeviceInfo:true;
  27. bool bRecreateDeviceInfo = _DetectingMacToggle1.isOn ? false : true;
  28. smartBowHelper1.Connect(userTags, deviceId, bRecreateDeviceInfo);
  29. }
  30. public void ClearDeviceInfo1()
  31. {
  32. smartBowHelper1.ClearDeviceInfo(userTags, deviceId);
  33. }
  34. public void ClearAllDeviceInfo()
  35. {
  36. ClearDeviceInfo1();
  37. }
  38. public void getAllDeviceInfo()
  39. {
  40. AimDeviceInfo aimDeviceInfo1 = smartBowHelper1.GetDeviceInfo(userTags, deviceId);
  41. Debug.Log("设备1:" + JsonUtility.ToJson(aimDeviceInfo1));
  42. }
  43. }