using SC.XR.Unity; using System.Collections.Generic; using TMPro; using UnityEngine; using static API_GSXR_Slam; public class HostInfo : MonoBehaviour { #region CanvasText [SerializeField] private TextMeshProUGUI XRType; [SerializeField] private TextMeshProUGUI DeviceName; [SerializeField] private TextMeshProUGUI SN; [SerializeField] private TextMeshProUGUI Internal_VERSION; [SerializeField] private TextMeshProUGUI IsSupportController; [SerializeField] private TextMeshProUGUI IsSupportHandTracking; [SerializeField] private TextMeshProUGUI IsSupportMap; [SerializeField] private TextMeshProUGUI IsSupportPanel; [SerializeField] private TextMeshProUGUI BatteryLevel; [SerializeField] private TextMeshProUGUI accelerometer; [SerializeField] private TextMeshProUGUI gyro_gravity; [SerializeField] private TextMeshProUGUI head_Position; [SerializeField] private TextMeshProUGUI head_Rotation; [SerializeField] private TextMeshProUGUI L_renderer; [SerializeField] private TextMeshProUGUI R_renderer; [SerializeField] private TextMeshProUGUI Volume; [SerializeField] private TextMeshProUGUI WIFI; [SerializeField] private TextMeshProUGUI Back; [SerializeField] private TextMeshProUGUI Enter; [SerializeField] private GameObject Headsetbutton; #endregion public static string xrType; private Gyroscope gyro; List list = new List(); private void Awake() { API_GSXR_Slam.GSXR_Add_InitializedCallBack(ShowDeviceInfo); } private void Start() { gyro = Input.gyro; gyro.enabled = true; } private void Update() { //if (API_GSXR_Slam.SlamManager == null && !API_GSXR_Slam.SlamManager.IsRunning) //{ // return; //} ShowHeadSensor(); ShowKeyState(); } private void LateUpdate() { //if (API_GSXR_Slam.SlamManager == null && !API_GSXR_Slam.SlamManager.IsRunning) //{ // return; //} ShowRenderer(); ShowOtherInfo(); } private void OnDestroy() { API_GSXR_Slam.GSXR_Remove_InitializedCallBack(ShowDeviceInfo); } private void ShowDeviceInfo() { if (GSXR_Is_SlamInitialized()) { xrType = API_GSXR_Slam.plugin.GSXR_Get_XRType().ToString(); XRType.text = "XRType:" + xrType; DeviceName.text = "DeviceName:" + API_GSXR_Slam.plugin.GSXR_Get_DeviceName(); if (API_GSXR_Slam.plugin.GSXR_Get_DeviceName() != "Sonic") { Headsetbutton.gameObject.SetActive(false); } SN.text = "SN:" + API_GSXR_Slam.plugin.SN; Internal_VERSION.text = "Internal_VERSION:" + API_GSXR_Slam.plugin.GSXR_Get_InternalVersion(); IsSupportController.text = "Controller:" + (API_GSXR_Slam.plugin.GSXR_Is_SupportController()==true? "Yes":"No"); IsSupportHandTracking.text = "HandTracking:" + (API_GSXR_Slam.plugin.GSXR_Is_SupportHandTracking() == true ? "Yes" : "No"); IsSupportMap.text = "SpatialAwareness:" + (API_GSXR_Slam.plugin.GSXR_Support_Map() == true ? "Yes" : "No"); IsSupportPanel.text = "PlaneDetection:" + (API_GSXR_Slam.plugin.GSXR_Support_Panel() == true ? "Yes" : "No"); } } private void ShowHeadSensor() { accelerometer.text = "Accelerometer:" + Input.acceleration; gyro_gravity.text = "Gyro.Gravity:" + gyro.gravity; head_Position.text = "Position:" + SlamManager.head.position.ToString("f3"); head_Rotation.text = "Rotation:" + SlamManager.head.rotation.ToString("f3"); } private void ShowOtherInfo() { if (GSXR_Is_SlamInitialized()) { BatteryLevel.text = "BatteryLevel:" + API_Module_BatteryStatus.BatteryLevel; Volume.text = "Volume:"+ API_Module_DetectorSystem_Volume.GetVolume().ToString(); WIFI.text = "WIFI:"+ (NetStatus.Instance.SCIsConnectWifi()? "Connected":"Disconnected"); } } private void ShowRenderer() { if (GSXR_Is_SlamInitialized()) { list = GSXR_Get_RenderTexure(); if (list.Count > 0 && list[0] != null) { L_renderer.text = "Left eye render resolution:" + list[0].width + " * " + list[0].height; R_renderer.text = "Right eye render resolution:" + list[1].width + " * " + list[1].height; } } } private void ShowKeyState() { if (API_GSXR_Slam.plugin.GSXR_Get_DeviceName() == "Sonic") { if (Input.GetKeyDown(KeyCode.JoystickButton0)) { Enter.text = "Enter: Down"; } if (Input.GetKeyUp(KeyCode.JoystickButton0)) { Enter.text = "Enter: Up"; } if (Input.GetKeyDown(KeyCode.Escape)) { Back.text = "Back: Down"; } if (Input.GetKeyUp(KeyCode.Escape)) { Back.text = "Back: Up"; } } } }