Test.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. using NibiruTask;
  2. using Nxr.Internal;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class Test : MonoBehaviour
  6. {
  7. public Text wifiEnabledText;
  8. public Text bluetoothEnabledText;
  9. void Start()
  10. {
  11. // var isInit = NxrSensor.Instance.InitLibrary();
  12. // Debug.Log("NxrSensorInit:" + isInit);
  13. // mainCamera = Camera.main;
  14. // NxrViewer.Instance.sleepTimeoutMode = SleepTimeoutMode.SYSTEM_SETTING;
  15. // NxrViewer.Instance.GetNibiruService().RequsetPermission(new []
  16. // {
  17. // "android.permission.ACCESS_WIFI_STATE",
  18. // "android.permission.CHANGE_WIFI_STATE"
  19. // });
  20. NibiruTaskApi.SetInstallSuccessCallback(InstallSuccess);
  21. NibiruTaskApi.SetInstallFailedCallback(InstallFailed);
  22. NibiruTaskApi.SetUninstallSuccessCallback(UninstallSuccess);
  23. NibiruTaskApi.SetUninstallFailedCallback(UninstallFailed);
  24. }
  25. void InstallSuccess(string filePath, string packageName)
  26. {
  27. Debug.Log("InstallSuccessEvent:"+filePath+"---"+packageName);
  28. }
  29. void InstallFailed(string filePath, string packageName)
  30. {
  31. Debug.Log("InstallFailedEvent:"+filePath+"---"+packageName);
  32. }
  33. void UninstallSuccess(string packageName)
  34. {
  35. Debug.Log("UninstallSuccessEvent:"+packageName);
  36. }
  37. void UninstallFailed(string packageName)
  38. {
  39. Debug.Log("UninstallFailedEvent:"+packageName);
  40. }
  41. // private bool isStart;
  42. //
  43. // private float time;
  44. //
  45. // public Transform cube;
  46. //
  47. // private Camera mainCamera;
  48. // Update is called once per frame
  49. void Update()
  50. {
  51. // if (isStart)
  52. // {
  53. // time += Time.deltaTime;
  54. // if (time >= 0.3f)
  55. // {
  56. // NxrSensor.Instance.DetectTags("36h11", 0.16);
  57. // time = 0.0f;
  58. // }
  59. // }
  60. if(wifiEnabledText) wifiEnabledText.text = "WifiEnabled:" +NibiruTaskApi.IsWifiEnabled();
  61. if(bluetoothEnabledText) bluetoothEnabledText.text = "BluetoothEnabled:" + NibiruTaskApi.IsBluetoothEnabled();
  62. if (Input.GetKeyUp(KeyCode.Escape))
  63. {
  64. Application.Quit();
  65. }
  66. }
  67. // public void Click()
  68. // {
  69. // Debug.Log("fff-Unity-Click1");
  70. // isStart = !isStart;
  71. // time = 0.0f;
  72. // Debug.Log("fff-Unity-Click2");
  73. // }
  74. public void Click1()
  75. {
  76. NibiruTaskApi.SetWifiEnable(true);
  77. }
  78. public void Click2()
  79. {
  80. NibiruTaskApi.SetWifiEnable(false);
  81. }
  82. public void Click3()
  83. {
  84. NibiruTaskApi.SetBluetoothEnable(true);
  85. }
  86. public void Click4()
  87. {
  88. NibiruTaskApi.SetBluetoothEnable(false);
  89. }
  90. public void Click5()
  91. {
  92. NibiruTaskApi.GoToControllerDriver();
  93. }
  94. public void Click6()
  95. {
  96. NibiruTaskApi.InstallApk(NxrViewer.Instance.GetStoragePath()+"/Sensor_List.apk");
  97. // NibiruTaskApi.InstallApk("1");
  98. }
  99. public void Click7()
  100. {
  101. NibiruTaskApi.UninstallApk("com.miian.android.sensors");
  102. }
  103. string numberList<T>(T[] array)
  104. {
  105. var str = "";
  106. foreach (var element in array)
  107. {
  108. str += element+" ";
  109. }
  110. return str;
  111. }
  112. }