| | |
| | | /// </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] |
| | |
| | | [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; |
| | | |
| | |
| | | { |
| | | 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 |
| | |
| | | |
| | | 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() |