You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
CrowdControl/Assets/3rd/D2D_Scripts/UI/DotView.cs

35 lines
737 B
C#

3 months ago
using D2D.Common;
using D2D.Utilities;
using UnityEngine;
namespace D2D.UI
{
public abstract class DotView : MonoBehaviour
{
public abstract TrackableValue<int> Trackable { get; }
private Dot[] _dots;
private void OnEnable()
{
_dots = GetComponentsInChildren<Dot>();
Trackable.Changed += Redraw;
Redraw(Trackable.Value);
}
private void OnDisable()
{
Trackable.Changed -= Redraw;
}
private void Redraw(int count)
{
_dots.ForEach(d => d.IsFilled = false);
for (int i = 0; i < count; i++)
_dots[i].IsFilled = true;
}
}
}