49 lines
1.4 KiB
C#
49 lines
1.4 KiB
C#
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;
|
|
private bool isPressingX = false;
|
|
|
|
private void Start()
|
|
{
|
|
infoPanel.SetActive(false);
|
|
if (showInfoPanel != null) {
|
|
showInfoPanel.action.Enable();
|
|
showInfoPanel.action.performed += ShowRobotInfoPanel;
|
|
}
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
if (showInfoPanel != null)
|
|
{
|
|
showInfoPanel.action.performed -= ShowRobotInfoPanel;
|
|
}
|
|
}
|
|
|
|
public void ShowRobotInfoPanel(InputAction.CallbackContext obj)
|
|
{
|
|
if (!isPressingX)
|
|
{
|
|
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);
|
|
}
|
|
isPressingX = !isPressingX;
|
|
}
|
|
} |