123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199 |
- // Copyright 2016 Nibiru. All rights reserved.
- using System;
- using UnityEngine;
- using UnityEngine.UI;
- using NibiruTask;
- using Nxr.Internal;
- namespace NXR.Samples
- {
- public class SystemApiScript : MonoBehaviour
- {
- Text InfoText,pathText , macAddressText, deviceIdText,sixDofPluginStatusText;
- string info = "";
- string path = "";
- // Use this for initialization
- void Start()
- {
- GameObject pathObj = GameObject.Find("FilePath");
- if (pathObj != null)
- {
- pathText = pathObj.GetComponent<Text>();
- }
- GameObject infoObj = GameObject.Find("SystemInfo");
- if (infoObj != null)
- {
- InfoText = infoObj.GetComponent<Text>();
- }
- NibiruTaskApi.setSelectionCallback(onSelectionResult);
-
- GameObject macAddressObj = GameObject.Find("MacAddress");
- if (macAddressObj != null)
- {
- macAddressText = macAddressObj.GetComponent<Text>();
- macAddressText.text = "MacAddress: " + NibiruTaskApi.GetMacAddress();
- }
-
- GameObject deviceIdObj = GameObject.Find("DeviceId");
- if (deviceIdObj != null)
- {
- deviceIdText = deviceIdObj.GetComponent<Text>();
- deviceIdText.text = "DeviceId: " + NibiruTaskApi.GetDeviceId();
- }
-
- GameObject sixDofPluginStatusObj = GameObject.Find("SixDofPluginStatus");
- if (sixDofPluginStatusObj != null)
- {
- sixDofPluginStatusText = sixDofPluginStatusObj.GetComponent<Text>();
- sixDofPluginStatusText.text = "SixDof Plugin Status: [Declared " + NibiruTaskApi.IsPluginDeclared(PLUGIN_ID.SIX_DOF)
- + "],\n [Suppored " + NibiruTaskApi.IsPluginSupported(PLUGIN_ID.SIX_DOF) + "]";
- }
- NibiruTaskApi.SetInstallSuccessCallback(InstallSuccess);
- NibiruTaskApi.SetInstallFailedCallback(InstallFailed);
- NibiruTaskApi.SetUninstallSuccessCallback(UninstallSuccess);
- NibiruTaskApi.SetUninstallFailedCallback(UninstallFailed);
- }
-
- void InstallSuccess(string filePath, string packageName)
- {
- Debug.Log("InstallSuccessEvent:"+filePath+"---"+packageName);
- }
-
- void InstallFailed(string filePath, string packageName)
- {
- Debug.Log("InstallFailedEvent:"+filePath+"---"+packageName);
- }
-
- void UninstallSuccess(string packageName)
- {
- Debug.Log("UninstallSuccessEvent:"+packageName);
- }
-
- void UninstallFailed(string packageName)
- {
- Debug.Log("UninstallFailedEvent:"+packageName);
- }
- public void onSelectionResult(AndroidJavaObject task)
- {
- path = NibiruTaskApi.GetResultPathFromSelectionTask(task);
- }
- // Update is called once per frame
- void Update()
- {
- if (InfoText != null)
- {
- InfoText.text = "SystemInfo: " + info;
- }
-
- if (pathText != null)
- {
- pathText.text = "GetFilePath: " + path;
- }
- }
- public void OpenVideoPlayer()
- {
- //NvrViewer.Instance.OpenVideoPlayer(NvrViewer.Instance.GetStoragePath() + "/nibiru.mp4", 0, 2, 1);
- NibiruTaskApi.OpenVideoPlayer("sdcard/nibiru.mp4");
- }
- public void OpenSettings()
- {
- NibiruTaskApi.OpenSettingsMain();
- }
- public void OpenBrowerExplorer()
- {
- NibiruTaskApi.OpenBrowerExplorer("http://www.inibiru.com");
- }
- public void GetSystemInfo()
- {
- info = "GetVRVersion:" + NibiruTaskApi.GetVRVersion() + "\n"
- + "GetOSVersion:" + NibiruTaskApi.GetOSVersion() + "\n"
- + "GetSysSleepTime:" + NibiruTaskApi.GetSysSleepTime() + "\n"
- + "GetCurrentLanguage:" + NibiruTaskApi.GetCurrentLanguage() + "\n"
- + "GetCurrentTimezone:" + NibiruTaskApi.GetCurrentTimezone() + "\n"
- + "GetDeviceName:" + NibiruTaskApi.GetDeviceName() + "\n";
- }
- public void OpenImage()
- {
- NibiruTaskApi.OpenImageGallery("sdcard/nibiru.png");
- }
- public void GetFilePath()
- {
- NibiruTaskApi.GetFilePath("sdcard");
- }
- public void OpenFileExploer()
- {
- NibiruTaskApi.OpenFileExplorer("sdcard");
- }
- public void SetIpd()
- {
- NxrViewer.Instance.SetIpd(0.040f);
- }
- public void ResetIpd()
- {
- NxrViewer.Instance.ResetIpd();
- }
- public void LaunchSDKDemo()
- {
- Debug.Log("LaunchSDKDemo");
- NibiruTaskApi.LaunchAppByPkgName("com.nibiru.vr.lib2.test");
- }
-
- public void OpenWiFi()
- {
- NibiruTaskApi.SetWifiEnable(true);
- }
-
- public void CloseWiFi()
- {
-
- NibiruTaskApi.SetWifiEnable(false);
- }
-
- public void OpenBluetooth()
- {
- NibiruTaskApi.SetBluetoothEnable(true);
- }
-
- public void CloseBluetooth()
- {
- NibiruTaskApi.SetBluetoothEnable(false);
- }
- public void InstallApk()
- {
- NibiruTaskApi.InstallApk(NxrViewer.Instance.GetStoragePath()+"/Sensor_List.apk");
- }
-
- public void UninstallApk()
- {
- NibiruTaskApi.UninstallApk("com.miian.android.sensors");
- }
-
- public void InstallAndStartApk()
- {
- NibiruTaskApi.InstallAndStartApk(NxrViewer.Instance.GetStoragePath()+"/Sensor_List.apk");
- }
-
- public void GoToControllerDriver()
- {
- NibiruTaskApi.GoToControllerDriver();
- }
- }
- }
|