using TMPro; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.XR; public class RobotInfoView : MonoBehaviour { // --- ·Îº¿ Á¤º¸ ÆÐ³Î --- [SerializeField] private Transform leftControllerTransform; [SerializeField] private GameObject infoPanel; [SerializeField] public TextMeshProUGUI motorState; [SerializeField] public GameObject motorON; [SerializeField] public GameObject motorOFF; public InputActionReference showInfoPanel; public InputActionReference hideInfoPanel; private bool isPressingY = false; private void Start() { infoPanel.SetActive(false); if (showInfoPanel != null) { showInfoPanel.action.Enable(); showInfoPanel.action.performed += ShowRobotInfoPanel; } if (hideInfoPanel != null) { hideInfoPanel.action.Enable(); hideInfoPanel.action.performed += HideRobotInfoPanel; } } private void OnDestroy() { if (showInfoPanel != null) { showInfoPanel.action.performed -= ShowRobotInfoPanel; } if (hideInfoPanel != null) { hideInfoPanel.action.performed -= HideRobotInfoPanel; } } private void ShowRobotInfoPanel(InputAction.CallbackContext obj) { if (!isPressingY) { infoPanel.transform.SetParent(leftControllerTransform); infoPanel.transform.localPosition = new Vector3(0f, 0.2f, 0f); infoPanel.transform.localRotation = new Quaternion(0f, 180f, 0f, 0f); infoPanel.SetActive(true); } else { infoPanel.SetActive(false); } isPressingY = !isPressingY; } private void HideRobotInfoPanel(InputAction.CallbackContext obj) { infoPanel.SetActive(false); } }