using System; using System.Collections; using System.Collections.Generic; 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 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) { // Match the Y rotation of the MenuRotator to the Camera Vector3 cameraRotation = Camera.transform.eulerAngles; Vector3 menuRotatorRotation = MenuRotator.transform.eulerAngles; // Update only the Y rotation, keep X and Z unchanged menuRotatorRotation.y = cameraRotation.y; MenuRotator.transform.eulerAngles = menuRotatorRotation; // Set the menu rotator position to that of the camera MenuRotator.transform.position = Camera.transform.position; canvas.enabled = !canvas.enabled; } // Start is called before the first frame update void Start() { Floor1Button.GetComponent