using SC.XR.Unity.Module_InputSystem; using System.Collections; using System.Collections.Generic; using UnityEngine; /// /// 编辑移动场景 /// public class DragManager : MonoSingleton { public TriggerState triggerState; public Transform rightKS; public Transform leftKS; private Transform selectTrigger; private Vector3 selectTOldPos; private Vector3 selectTOldRot; /// /// 编辑状态 /// public bool state; // Start is called before the first frame update void Start() { triggerState = TriggerState.No; DispatcherBase.KeyDownDelegateRegister(AnyDown); DispatcherBase.KeyUpDelegateRegister(AnyUp); } // Update is called once per frame void Update() { if (state) { if (triggerState != TriggerState.No && selectTrigger != null) { MachineRoomManager.Instance.transform.eulerAngles -= new Vector3(0, selectTOldRot.y - selectTrigger.eulerAngles.y, 0); selectTOldRot = selectTrigger.eulerAngles; //MachineRoomManager.Instance.transform.position -= new Vector3(selectTOldPos.x - selectTrigger.position.x, 0, selectTOldPos.z - selectTrigger.position.z); //selectTOldPos = selectTrigger.position; MachineRoomManager.Instance.transform.position -= new Vector3(selectTOldPos.x - selectTrigger.position.x, selectTOldPos.y - selectTrigger.position.y, selectTOldPos.z - selectTrigger.position.z); selectTOldPos = selectTrigger.position; } } } private void AnyUp(InputKeyCode keyCode, InputDevicePartBase part) { // UILogManager.Instance.SendLogText(3, part.PartType.ToString()); if (part.PartType == InputDevicePartType.KSRight && triggerState == TriggerState.RTrigger) { // UILogManager.Instance.SendLogText(3, "RTriggerUp"); triggerState = TriggerState.No; selectTrigger = null; selectTOldPos = Vector3.zero; selectTOldRot = Vector3.zero; } if (part.PartType == InputDevicePartType.KSLeft && triggerState == TriggerState.LTrigger) { // UILogManager.Instance.SendLogText(3, "LTriggerUp"); triggerState = TriggerState.No; selectTrigger = null; selectTOldPos = Vector3.zero; selectTOldRot = Vector3.zero; } } private void AnyDown(InputKeyCode keyCode, InputDevicePartBase part) { // UILogManager.Instance.SendLogText(3, part.PartType.ToString()); if (part.PartType == InputDevicePartType.KSRight && triggerState == TriggerState.No) { // UILogManager.Instance.SendLogText(3, "RTriggerDown"); triggerState = TriggerState.RTrigger; selectTrigger = rightKS; selectTOldPos = selectTrigger.position; selectTOldRot = selectTrigger.eulerAngles; } if (part.PartType == InputDevicePartType.KSLeft && triggerState == TriggerState.No) { triggerState = TriggerState.LTrigger; selectTrigger = leftKS; selectTOldPos = selectTrigger.position; selectTOldRot = selectTrigger.eulerAngles; } } } public enum TriggerState { No, RTrigger, LTrigger }