47 lines
1.4 KiB
C#
47 lines
1.4 KiB
C#
using OnlyScove.Scripts;
|
|
using UnityEngine;
|
|
using TMPro;
|
|
|
|
namespace UI
|
|
{
|
|
public class MyUIDisplay : MonoBehaviour
|
|
{
|
|
public PlayerDebugProvider playerDebugProvider;
|
|
|
|
[Header("UI Prompt")]
|
|
public GameObject interactionPromptContainer;
|
|
public TextMeshProUGUI interactionPromptText;
|
|
|
|
private void Start()
|
|
{
|
|
if (playerDebugProvider == null)
|
|
playerDebugProvider = FindFirstObjectByType<PlayerDebugProvider>();
|
|
|
|
// Luôn ẩn lúc bắt đầu
|
|
if (interactionPromptContainer != null)
|
|
interactionPromptContainer.SetActive(false);
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (playerDebugProvider == null || interactionPromptContainer == null) return;
|
|
|
|
IInteractable interactable = playerDebugProvider.GetActiveInteractable();
|
|
|
|
if (interactable != null)
|
|
{
|
|
// Hiện UI tại vị trí cố định bạn đã đặt trong Canvas
|
|
interactionPromptContainer.SetActive(true);
|
|
|
|
if (interactionPromptText != null)
|
|
{
|
|
interactionPromptText.text = interactable.InteractionPrompt;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
interactionPromptContainer.SetActive(false);
|
|
}
|
|
}
|
|
}
|
|
} |