42 lines
903 B
C#
42 lines
903 B
C#
|
|
using UnityEngine;
|
||
|
|
using UnityEngine.UI;
|
||
|
|
using TMPro;
|
||
|
|
|
||
|
|
public class ShootButtonUI : MonoBehaviour
|
||
|
|
{
|
||
|
|
[Header("References")]
|
||
|
|
public TMP_Text ammoText;
|
||
|
|
|
||
|
|
private ShootButton shootButton;
|
||
|
|
private int lastCurrent;
|
||
|
|
private int lastMax;
|
||
|
|
|
||
|
|
void Awake()
|
||
|
|
{
|
||
|
|
shootButton = GetComponent<ShootButton>();
|
||
|
|
}
|
||
|
|
|
||
|
|
public void UpdateAmmoUI(int current, int max)
|
||
|
|
{
|
||
|
|
lastCurrent = current;
|
||
|
|
lastMax = max;
|
||
|
|
|
||
|
|
if (ammoText != null)
|
||
|
|
ammoText.text = $"{current}/{max}";
|
||
|
|
}
|
||
|
|
|
||
|
|
public void SetReloading(bool reloading)
|
||
|
|
{
|
||
|
|
if (ammoText != null)
|
||
|
|
{
|
||
|
|
if (reloading)
|
||
|
|
ammoText.text = "Reload";
|
||
|
|
else
|
||
|
|
ammoText.text = $"{lastCurrent}/{lastMax}";
|
||
|
|
}
|
||
|
|
|
||
|
|
// 버튼 입력 차단/해제
|
||
|
|
if (shootButton != null)
|
||
|
|
shootButton.SetDisabled(reloading);
|
||
|
|
}
|
||
|
|
}
|