Что я сдал
This commit is contained in:
1 parent
24b1157026
commit
a5665f0101
2838 files changed
+129953
-1304
No files matched your search
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Code.GameplayServices;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Code.UI
|
||||
{
|
||||
public class ScoreTable : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Transform scoreDataBox;
|
||||
[SerializeField] private ScoreDataView scoreDataPrefab;
|
||||
[SerializeField] private Button exitButton;
|
||||
private List<ScoreDataView> _scoreDataViews = new();
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
exitButton.onClick.AddListener(HideTable);
|
||||
HideTable();
|
||||
}
|
||||
private void OnDestroy()
|
||||
{
|
||||
exitButton.onClick.RemoveListener(HideTable);
|
||||
}
|
||||
|
||||
private void HideTable() => gameObject.SetActive(false);
|
||||
private void OnEnable()
|
||||
{
|
||||
foreach (var score in PlayerScoreService.Instance.Scores)
|
||||
{
|
||||
var scoreData = Instantiate(scoreDataPrefab, scoreDataBox);
|
||||
scoreData.SetScoreData(score);
|
||||
_scoreDataViews.Add(scoreData);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
foreach (var scoreDataView in _scoreDataViews)
|
||||
{
|
||||
Destroy(scoreDataView.gameObject);
|
||||
}
|
||||
_scoreDataViews.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user