using SC.XR.Unity; using SC.XR.Unity.Module_InputSystem; using SC.XR.Unity.Module_InputSystem.InputDeviceGC.KS; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class SwitchMode : MonoBehaviour { bool is6Dof = true; // Start is called before the first frame update void Start() { API_GSXR_Module_InputSystem.GSXR_KeyDownDelegateRegister(Set6DofBtn); } // Update is called once per frame void Update() { } private void OnDestroy() { API_GSXR_Module_InputSystem.GSXR_KeyDownDelegateUnRegister(Set6DofBtn); } InputDeviceKSPart kspart; InputDeviceKS ks; public void Set6DofBtn(InputKeyCode inputKeyCode,InputDevicePartBase part) { if (part.inputDeviceBase.inputDeviceType == InputDeviceType.KS && (inputKeyCode == InputKeyCode.A||inputKeyCode==InputKeyCode.X)) { is6Dof = !is6Dof; SetMode(is6Dof); } } public void SetMode(bool is6dof) { API_GSXR_Slam.plugin.GSXR_Set_6Dof(is6dof); ks = API_GSXR_Module_InputSystem_KS.GSXR_KSDevice; foreach (var item in ks.inputDevicePartList) { kspart = item as InputDeviceKSPart; if (!is6dof) { kspart.inputDataGetKS.inputDataGetKSPosture.isKS_3DofMode = true; kspart.inputDeviceKSPartUI.ModelGC._modelPositionDeltaWithDevice.z = 0.15f; kspart.inputDataKS.PostureType = SC.XR.Unity.Module_InputSystem.InputDeviceGC.PostureType._3Dof; kspart.inputDataGetKS.inputDataGetKSPosture.delayOffset = -(Vector3.forward * 0.3f); } else { kspart.inputDataGetKS.inputDataGetKSPosture.isKS_3DofMode = false; kspart.inputDataKS.PostureType = SC.XR.Unity.Module_InputSystem.InputDeviceGC.PostureType._6Dof; kspart.inputDeviceKSPartUI.ModelGC._modelPositionDeltaWithDevice.z = 0.0f; kspart.inputDataGetKS.inputDataGetKSPosture.delayOffset = Vector3.zero; } } } }