123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- using SC.XR.Unity.Module_InputSystem;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- /// <summary>
- /// 编辑移动场景
- /// </summary>
- public class DragManager : MonoSingleton<DragManager>
- {
- public TriggerState triggerState;
- public Transform rightKS;
- public Transform leftKS;
- private Transform selectTrigger;
- private Vector3 selectTOldPos;
- private Vector3 selectTOldRot;
- /// <summary>
- /// 编辑状态
- /// </summary>
- 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
- }
|