Pickup Pizza und so
This commit is contained in:
43
3d Prototyp/Assets/Scripts/UiController.cs
Normal file
43
3d Prototyp/Assets/Scripts/UiController.cs
Normal file
@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class UiController : MonoBehaviour
|
||||
{
|
||||
[Header("Objects")]
|
||||
[SerializeField]
|
||||
private Pickupper _pickupper;
|
||||
|
||||
[Header("UI Elements")]
|
||||
[SerializeField]
|
||||
private GameObject _actionDisplay;
|
||||
[SerializeField]
|
||||
private TextMeshProUGUI _actionText;
|
||||
[SerializeField]
|
||||
private Button _prevActionButton;
|
||||
[SerializeField]
|
||||
private Button _nextActionButton;
|
||||
|
||||
void Update()
|
||||
{
|
||||
UpdateActionDisplay();
|
||||
}
|
||||
|
||||
private void UpdateActionDisplay()
|
||||
{
|
||||
bool show = _pickupper.PickupablesInRange.Count > 0;
|
||||
|
||||
_actionDisplay.SetActive(show);
|
||||
|
||||
if (!show)
|
||||
return;
|
||||
|
||||
_actionText.text = $"{_pickupper.Selected.Name}";
|
||||
|
||||
_prevActionButton.interactable = _pickupper.CanSelectPrevious;
|
||||
_nextActionButton.interactable = _pickupper.CanSelectNext;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user