상호작용 시 모달 UI 추가(임시)

기타 디버깅 로그 제거
This commit is contained in:
2026-02-03 21:32:16 +09:00
parent 02f5aa869a
commit 965a4a25aa
22 changed files with 1082 additions and 363 deletions

View File

@@ -0,0 +1,90 @@
using TMPro;
using UnityEngine;
namespace Northbound
{
public class InteractableModal : MonoBehaviour
{
[Header("UI References")]
[SerializeField] private GameObject modalPanel;
[SerializeField] private TextMeshProUGUI keyText;
[SerializeField] private TextMeshProUGUI interactText;
[Header("Settings")]
[SerializeField] private string defaultKey = "E";
private IInteractable _currentInteractable;
private Canvas _parentCanvas;
private void Awake()
{
_parentCanvas = GetComponentInParent<Canvas>();
}
private void Start()
{
if (modalPanel != null)
{
modalPanel.SetActive(false);
}
}
public void ShowModal(IInteractable interactable)
{
if (interactable == null)
{
HideModal();
return;
}
_currentInteractable = interactable;
if (modalPanel != null)
{
modalPanel.SetActive(true);
UpdateModalContent();
}
}
public void HideModal()
{
_currentInteractable = null;
if (modalPanel != null)
{
modalPanel.SetActive(false);
}
}
public void UpdateModalContent()
{
if (_currentInteractable == null)
return;
if (keyText != null)
{
keyText.text = defaultKey;
}
if (interactText != null)
{
string prompt = _currentInteractable.GetInteractionPrompt();
interactText.text = ExtractInteractText(prompt);
}
}
private string ExtractInteractText(string prompt)
{
if (string.IsNullOrEmpty(prompt))
return string.Empty;
int startIndex = prompt.IndexOf(']');
if (startIndex >= 0 && startIndex + 1 < prompt.Length)
{
return prompt.Substring(startIndex + 1).Trim();
}
return prompt;
}
}
}