43 lines
1.0 KiB
C#
43 lines
1.0 KiB
C#
using System;
|
|
using UnityEngine;
|
|
|
|
public class CountersPanel : MonoBehaviour, ICompletable
|
|
{
|
|
public event Action OnComplete;
|
|
|
|
[SerializeField] private CounterRecordView _recordViewPrefab;
|
|
[SerializeField] private Transform _group;
|
|
[SerializeField] private InSignal _exitSignal/* = InSignal.UpRight*/;
|
|
|
|
private void OnEnable() => Generate();
|
|
private void OnDisable() => Clear();
|
|
private void OnDestroy() => Clear();
|
|
|
|
private void Update()
|
|
{
|
|
if (In.GetButtonDown(_exitSignal)) Exit();
|
|
}
|
|
|
|
private void Generate()
|
|
{
|
|
//foreach (var record in CountersSystem.Records)
|
|
//{
|
|
// var go = Instantiate(_recordViewPrefab.gameObject, _group);
|
|
// go.GetComponent<CounterRecordView>().Configure(record);
|
|
//}
|
|
}
|
|
|
|
private void Exit()
|
|
{
|
|
OnComplete?.Invoke();
|
|
gameObject.SetActive(false);
|
|
}
|
|
|
|
private void Clear()
|
|
{
|
|
for (int i = _group.childCount - 1; i >= 0; i--)
|
|
{
|
|
Destroy(_group.GetChild(i).gameObject);
|
|
}
|
|
}
|
|
} |