update tùm lum tùm la
This commit is contained in:
@@ -8,35 +8,40 @@ namespace UI
|
||||
{
|
||||
public PlayerDebugProvider playerDebugProvider;
|
||||
|
||||
[Header("Text Fields")]
|
||||
public TextMeshProUGUI stateText;
|
||||
public TextMeshProUGUI groundedStatusText;
|
||||
public TextMeshProUGUI horizontalSpeedText;
|
||||
public TextMeshProUGUI verticaSpeedText;
|
||||
public TextMeshProUGUI moveInputText;
|
||||
public TextMeshProUGUI isSprintingText;
|
||||
[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) return;
|
||||
if (playerDebugProvider == null || interactionPromptContainer == null) return;
|
||||
|
||||
IInteractable interactable = playerDebugProvider.GetActiveInteractable();
|
||||
|
||||
if (stateText != null)
|
||||
stateText.text = "State: " + playerDebugProvider.CurrentState;
|
||||
if (interactable != null)
|
||||
{
|
||||
// Hiện UI tại vị trí cố định bạn đã đặt trong Canvas
|
||||
interactionPromptContainer.SetActive(true);
|
||||
|
||||
if (groundedStatusText != null)
|
||||
groundedStatusText.text = "Grounded: " + playerDebugProvider.GroundedStatus;
|
||||
|
||||
if (horizontalSpeedText != null)
|
||||
horizontalSpeedText.text = "Speed (H): " + playerDebugProvider.HorizontalSpeed.ToString("F2") + " m/s";
|
||||
|
||||
if (verticaSpeedText != null)
|
||||
verticaSpeedText.text = "Speed (V): " + playerDebugProvider.VerticalSpeed.ToString("F2") + " m/s";
|
||||
|
||||
if (moveInputText != null)
|
||||
moveInputText.text = "Input: " + playerDebugProvider.MoveInput.ToString();
|
||||
|
||||
if (isSprintingText != null)
|
||||
isSprintingText.text = "Sprinting: " + (playerDebugProvider.IsSprinting ? "YES" : "NO");
|
||||
if (interactionPromptText != null)
|
||||
{
|
||||
interactionPromptText.text = interactable.InteractionPrompt;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
interactionPromptContainer.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user