using SC.XR.Unity.Module_InputSystem; using UnityEngine; public class MoveChange : MonoBehaviour { [SerializeField] private GameObject moveGame; [SerializeField] private Transform parent; private bool isDown; private float y; void Start() { moveGame = GameObject.Find("ARSpaceForAll/mesh_test"); parent = GameObject.Find("ARSpaceForAll").transform; y = moveGame.transform.position.y; DispatcherBase.KeyDownDelegateRegister(keyDownEventDelegate); DispatcherBase.KeyUpDelegateRegister(keyUpEventDelegate); } private void keyUpEventDelegate(InputKeyCode keyCode, InputDevicePartBase part) { if (keyCode != InputKeyCode.Enter) { return; } Debug.Log("keyDownEventDelegate===>" + keyCode); moveGame.transform.parent = parent; isDown = false; } private void keyDownEventDelegate(InputKeyCode keyCode, InputDevicePartBase part) { if(keyCode != InputKeyCode.Enter) { return; } if (!SetSceneActive.active) return; Debug.Log("keyUpEventDelegate===>" + keyCode); #if UNITY_EDITOR moveGame.transform.parent = OpenXRCamera.Instance.head; #else switch (DeviceType.type) { case "Nreal": moveGame.transform.parent = API_GSXR_Module_InputSystem_KS.GSXR_KSRight.transform;// OpenXRCamera.Instance.head; break; case "A01": moveGame.transform.parent = OpenXRCamera.Instance.head; break; case "Phone": moveGame.transform.parent = OpenXRCamera.Instance.head; break; case "Rhinox": moveGame.transform.parent = API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDeviceKSPartUI.transform; break; default: moveGame.transform.parent = API_GSXR_Module_InputSystem_KS.GSXR_KSRight.transform;// OpenXRCamera.Instance.head; break; } #endif isDown = true; } void Update() { if (isDown && SetSceneActive.active) { moveGame.transform.eulerAngles = new Vector3(0, moveGame.transform.eulerAngles.y, 0); moveGame.transform.position = new Vector3(moveGame.transform.position.x, y, moveGame.transform.position.z); } } }