30 lines
682 B
C#
30 lines
682 B
C#
using System.Collections.Generic;
|
|
using HurricaneVR.Framework.Weapons.Guns;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
|
|
public class WeaponCountAmmoUI : MonoBehaviour
|
|
{
|
|
[SerializeField] private HVRGunBase gun;
|
|
[SerializeField] private List<TMP_Text> countTexts;
|
|
|
|
private int cachedCount = -1;
|
|
private void Update()
|
|
{
|
|
var count = 0;
|
|
if (gun != null && gun.Ammo != null)
|
|
{
|
|
count = gun.Ammo.CurrentCount;
|
|
}
|
|
|
|
if (count != cachedCount)
|
|
{
|
|
cachedCount = count;
|
|
foreach (var countText in countTexts)
|
|
{
|
|
countText.text = count.ToString();
|
|
}
|
|
}
|
|
}
|
|
}
|