SystemApiScript.cs 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. // Copyright 2016 Nibiru. All rights reserved.
  2. using System;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using NibiruTask;
  6. using Nxr.Internal;
  7. namespace NXR.Samples
  8. {
  9. public class SystemApiScript : MonoBehaviour
  10. {
  11. Text InfoText,pathText , macAddressText, deviceIdText,sixDofPluginStatusText;
  12. string info = "";
  13. string path = "";
  14. // Use this for initialization
  15. void Start()
  16. {
  17. GameObject pathObj = GameObject.Find("FilePath");
  18. if (pathObj != null)
  19. {
  20. pathText = pathObj.GetComponent<Text>();
  21. }
  22. GameObject infoObj = GameObject.Find("SystemInfo");
  23. if (infoObj != null)
  24. {
  25. InfoText = infoObj.GetComponent<Text>();
  26. }
  27. NibiruTaskApi.setSelectionCallback(onSelectionResult);
  28. GameObject macAddressObj = GameObject.Find("MacAddress");
  29. if (macAddressObj != null)
  30. {
  31. macAddressText = macAddressObj.GetComponent<Text>();
  32. macAddressText.text = "MacAddress: " + NibiruTaskApi.GetMacAddress();
  33. }
  34. GameObject deviceIdObj = GameObject.Find("DeviceId");
  35. if (deviceIdObj != null)
  36. {
  37. deviceIdText = deviceIdObj.GetComponent<Text>();
  38. deviceIdText.text = "DeviceId: " + NibiruTaskApi.GetDeviceId();
  39. }
  40. GameObject sixDofPluginStatusObj = GameObject.Find("SixDofPluginStatus");
  41. if (sixDofPluginStatusObj != null)
  42. {
  43. sixDofPluginStatusText = sixDofPluginStatusObj.GetComponent<Text>();
  44. sixDofPluginStatusText.text = "SixDof Plugin Status: [Declared " + NibiruTaskApi.IsPluginDeclared(PLUGIN_ID.SIX_DOF)
  45. + "],\n [Suppored " + NibiruTaskApi.IsPluginSupported(PLUGIN_ID.SIX_DOF) + "]";
  46. }
  47. NibiruTaskApi.SetInstallSuccessCallback(InstallSuccess);
  48. NibiruTaskApi.SetInstallFailedCallback(InstallFailed);
  49. NibiruTaskApi.SetUninstallSuccessCallback(UninstallSuccess);
  50. NibiruTaskApi.SetUninstallFailedCallback(UninstallFailed);
  51. }
  52. void InstallSuccess(string filePath, string packageName)
  53. {
  54. Debug.Log("InstallSuccessEvent:"+filePath+"---"+packageName);
  55. }
  56. void InstallFailed(string filePath, string packageName)
  57. {
  58. Debug.Log("InstallFailedEvent:"+filePath+"---"+packageName);
  59. }
  60. void UninstallSuccess(string packageName)
  61. {
  62. Debug.Log("UninstallSuccessEvent:"+packageName);
  63. }
  64. void UninstallFailed(string packageName)
  65. {
  66. Debug.Log("UninstallFailedEvent:"+packageName);
  67. }
  68. public void onSelectionResult(AndroidJavaObject task)
  69. {
  70. path = NibiruTaskApi.GetResultPathFromSelectionTask(task);
  71. }
  72. // Update is called once per frame
  73. void Update()
  74. {
  75. if (InfoText != null)
  76. {
  77. InfoText.text = "SystemInfo: " + info;
  78. }
  79. if (pathText != null)
  80. {
  81. pathText.text = "GetFilePath: " + path;
  82. }
  83. }
  84. public void OpenVideoPlayer()
  85. {
  86. //NvrViewer.Instance.OpenVideoPlayer(NvrViewer.Instance.GetStoragePath() + "/nibiru.mp4", 0, 2, 1);
  87. NibiruTaskApi.OpenVideoPlayer("sdcard/nibiru.mp4");
  88. }
  89. public void OpenSettings()
  90. {
  91. NibiruTaskApi.OpenSettingsMain();
  92. }
  93. public void OpenBrowerExplorer()
  94. {
  95. NibiruTaskApi.OpenBrowerExplorer("http://www.inibiru.com");
  96. }
  97. public void GetSystemInfo()
  98. {
  99. info = "GetVRVersion:" + NibiruTaskApi.GetVRVersion() + "\n"
  100. + "GetOSVersion:" + NibiruTaskApi.GetOSVersion() + "\n"
  101. + "GetSysSleepTime:" + NibiruTaskApi.GetSysSleepTime() + "\n"
  102. + "GetCurrentLanguage:" + NibiruTaskApi.GetCurrentLanguage() + "\n"
  103. + "GetCurrentTimezone:" + NibiruTaskApi.GetCurrentTimezone() + "\n"
  104. + "GetDeviceName:" + NibiruTaskApi.GetDeviceName() + "\n";
  105. }
  106. public void OpenImage()
  107. {
  108. NibiruTaskApi.OpenImageGallery("sdcard/nibiru.png");
  109. }
  110. public void GetFilePath()
  111. {
  112. NibiruTaskApi.GetFilePath("sdcard");
  113. }
  114. public void OpenFileExploer()
  115. {
  116. NibiruTaskApi.OpenFileExplorer("sdcard");
  117. }
  118. public void SetIpd()
  119. {
  120. NxrViewer.Instance.SetIpd(0.040f);
  121. }
  122. public void ResetIpd()
  123. {
  124. NxrViewer.Instance.ResetIpd();
  125. }
  126. public void LaunchSDKDemo()
  127. {
  128. Debug.Log("LaunchSDKDemo");
  129. NibiruTaskApi.LaunchAppByPkgName("com.nibiru.vr.lib2.test");
  130. }
  131. public void OpenWiFi()
  132. {
  133. NibiruTaskApi.SetWifiEnable(true);
  134. }
  135. public void CloseWiFi()
  136. {
  137. NibiruTaskApi.SetWifiEnable(false);
  138. }
  139. public void OpenBluetooth()
  140. {
  141. NibiruTaskApi.SetBluetoothEnable(true);
  142. }
  143. public void CloseBluetooth()
  144. {
  145. NibiruTaskApi.SetBluetoothEnable(false);
  146. }
  147. public void InstallApk()
  148. {
  149. NibiruTaskApi.InstallApk(NxrViewer.Instance.GetStoragePath()+"/Sensor_List.apk");
  150. }
  151. public void UninstallApk()
  152. {
  153. NibiruTaskApi.UninstallApk("com.miian.android.sensors");
  154. }
  155. public void InstallAndStartApk()
  156. {
  157. NibiruTaskApi.InstallAndStartApk(NxrViewer.Instance.GetStoragePath()+"/Sensor_List.apk");
  158. }
  159. public void GoToControllerDriver()
  160. {
  161. NibiruTaskApi.GoToControllerDriver();
  162. }
  163. }
  164. }