열차 목업의 내부 확인용 프로젝트
smchoi
2024-07-31 9fe33c1ae076b0f6501619388e6b4cc872b76f80
Assets/Korail/Scripts/XR/XRLever.cs
@@ -8,6 +8,13 @@
    /// </summary>
    public class XRLever : XRBaseInteractable
    {
        public enum LeverAxis
        {
            X,
            Y,
            Z
        }
        const float k_LeverDeadZone = 0.1f; // Prevents rapid switching between on and off states when right in the middle
        [SerializeField]
@@ -39,6 +46,13 @@
        [SerializeField]
        [Tooltip("Events to trigger when the lever deactivates")]
        UnityEvent m_OnLeverDeactivate = new UnityEvent();
        [SerializeField]
        LeverAxis m_Axis = LeverAxis.X;
        [SerializeField]
        Vector3 m_BaseDirection = new Vector3(0, 90, -90);
        IXRSelectInteractor m_Interactor;
@@ -159,7 +173,7 @@
        {
            var lookDirection = GetLookDirection();
            var lookAngle = Mathf.Atan2(lookDirection.x, lookDirection.y) * Mathf.Rad2Deg;
            Debug.Log("lookAngle : " + lookAngle);
            if (m_MinAngle < m_MaxAngle)
                lookAngle = Mathf.Clamp(lookAngle, m_MinAngle, m_MaxAngle);
            else
@@ -209,11 +223,23 @@
        void SetHandleAngle(float angle)
        {
            if (m_Handle != null)
                m_Handle.localRotation = Quaternion.Euler(angle, 90f, -90f);
            if (m_Handle == null) return;
            if (m_Axis == LeverAxis.X)
            {
                m_Handle.localRotation = Quaternion.Euler(angle, m_BaseDirection.y, m_BaseDirection.z);
            }
            else if (m_Axis == LeverAxis.Y)
            {
                m_Handle.localRotation = Quaternion.Euler(m_BaseDirection.x, angle, m_BaseDirection.z);
            }
            else
            {
                m_Handle.localRotation = Quaternion.Euler(m_BaseDirection.x, m_BaseDirection.y, angle);
            }
        }
        void OnDrawGizmosSelected()