44 lines
955 B
C#
44 lines
955 B
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class UI_FishBookMenu : MonoBehaviour
|
|
{
|
|
public PlayerProfile PlayerProfile;
|
|
|
|
public UI_FishRecordButton FishButtonTemplate;
|
|
|
|
public Transform ButtonParent;
|
|
|
|
public GameObject NoRecordsText;
|
|
|
|
private void OnEnable()
|
|
{
|
|
CreateFishMenuButtons();
|
|
}
|
|
|
|
private void CreateFishMenuButtons()
|
|
{
|
|
Clear();
|
|
List<FishData> fishRecords = PlayerProfile.FishRecords;
|
|
if (fishRecords.Count == 0)
|
|
{
|
|
NoRecordsText.SetActive(value: true);
|
|
return;
|
|
}
|
|
NoRecordsText.SetActive(value: false);
|
|
for (int i = 0; i < fishRecords.Count; i++)
|
|
{
|
|
Object.Instantiate(FishButtonTemplate, ButtonParent).Initialize(fishRecords[i]);
|
|
}
|
|
}
|
|
|
|
private void Clear()
|
|
{
|
|
UI_FishRecordButton[] componentsInChildren = ButtonParent.GetComponentsInChildren<UI_FishRecordButton>();
|
|
for (int i = 0; i < componentsInChildren.Length; i++)
|
|
{
|
|
Object.Destroy(componentsInChildren[i].gameObject);
|
|
}
|
|
}
|
|
}
|