using System; using System.Collections; using System.Collections.Generic; using Unity.XR.CoreUtils; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.LowLevel; using UnityEngine.UI; public class Menu : MonoBehaviour { public GameObject MenuRotator; public GameObject Floor1Panel; public GameObject Floor2Panel; public FloorButtonVisualizer Floor1Button; public FloorButtonVisualizer Floor2Button; public Camera Camera; public Image PlayericonFloor1; public Image PlayericonFloor2; public GameObject PlayericonFloor1Parent; public GameObject PlayericonFloor2Parent; public XROrigin Player; public InputActionReference openMenuAction; private Canvas canvas; // Values for setting the position of the player marker. Do not touch them without great cause. private Vector2 rotatedPlayerPos = new Vector2(); private float worldToMapAngle = 130.0f; private Vector2 VR_P1 = new Vector2(-77.4f, 10.1f); // - 71.2f (alumine punkt) private Vector2 VR_P2 = new Vector2(95.7f, -82.8f); private Vector2 IMG_P1 = new Vector2(-387.2f, 193.1f); // private Vector2 IMG_P2 = new Vector2(389.7f, -221.4f); // protected static float cameraToMapIconRotationOffset = -50; private float floor2UpperLimit = 9; private float floorsMidpointLimit = 2.5f; private float floor1LowerLimit = -5; private void Awake() { openMenuAction.action.Enable(); openMenuAction.action.performed += ToggleMenu; InputSystem.onDeviceChange += OnDeviceChange; canvas = GetComponent(); canvas.enabled = false; } private void ToggleMenu(InputAction.CallbackContext context) { // Get the camera's local Y rotation relative to the parent of MenuRotator float relativeYRotation = Camera.transform.localEulerAngles.y; // Apply the relative Y rotation to MenuRotator while keeping X and Z unchanged MenuRotator.transform.localEulerAngles = new Vector3(0, relativeYRotation, 0); // Set the menu position to match the camera's position in local space MenuRotator.transform.position = Camera.transform.position; // Toggle the menu visibility canvas.enabled = !canvas.enabled; } // Start is called before the first frame update void Start() { Floor1Button.GetComponent