update
This commit is contained in:
@@ -15,6 +15,7 @@ namespace UI
|
||||
private Label _noiseLabel;
|
||||
private Label _interactionLabel;
|
||||
private VisualElement _interactionPrompt;
|
||||
private Button _btnToggleView;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
@@ -29,6 +30,15 @@ namespace UI
|
||||
_noiseLabel = root.Q<Label>("noise-label");
|
||||
_interactionLabel = root.Q<Label>("interaction-text");
|
||||
_interactionPrompt = root.Q<VisualElement>("interaction-prompt");
|
||||
|
||||
_btnToggleView = root.Q<Button>("btn-toggle-view");
|
||||
if (_btnToggleView != null)
|
||||
{
|
||||
_btnToggleView.clicked += () => {
|
||||
var cam = Object.FindFirstObjectByType<CameraController>();
|
||||
if (cam != null) cam.ToggleCameraView();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
@@ -63,10 +73,13 @@ namespace UI
|
||||
_currentPlayer.OnNoiseLevelChanged += UpdateNoise;
|
||||
_currentPlayer.OnInteractableTargetChanged += UpdateInteraction;
|
||||
|
||||
// Cập nhật giá trị ban đầu
|
||||
UpdateHealth(_currentPlayer.Health);
|
||||
UpdateStamina(_currentPlayer.Stamina);
|
||||
UpdateNoise(_currentPlayer.NoiseLevel);
|
||||
// Cập nhật giá trị ban đầu - Kiểm tra xem đã Spawned chưa nếu là Network Object
|
||||
if (player.Object == null || player.Object.IsValid)
|
||||
{
|
||||
UpdateHealth(_currentPlayer.Health);
|
||||
UpdateStamina(_currentPlayer.Stamina);
|
||||
UpdateNoise(_currentPlayer.NoiseLevel);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateHealth(float health)
|
||||
|
||||
Reference in New Issue
Block a user