Files
ichni_Official/Assets/Scripts/UI/ChapterSelection/ChapterSelectionUIPage.cs

44 lines
1.2 KiB
C#
Raw Normal View History

2025-06-06 10:14:55 -04:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
2025-06-09 04:52:14 -04:00
using UnityEngine.UI;
2025-06-06 10:14:55 -04:00
namespace Ichni.UI
{
public class ChapterSelectionUIPage : UIPageBase
{
public RectTransform chapterContainer;
2025-06-09 04:52:14 -04:00
public HorizontalLayoutGroup containerLayoutGroup;
2025-08-11 14:04:06 -04:00
public Button settingsButton;
2025-06-06 10:14:55 -04:00
public GameObject chapterSelectionUIPrefab;
2025-08-11 14:04:06 -04:00
protected override void Awake()
{
base.Awake();
2025-08-22 14:54:40 -04:00
fadeInStartAction = Initialize;
2025-08-11 14:04:06 -04:00
settingsButton.onClick.AddListener(() =>
{
FadeOut();
MenuManager.instance.settingsUIPage.FadeIn();
});
}
2025-08-22 14:54:40 -04:00
private void Initialize()
2025-06-06 10:14:55 -04:00
{
2025-08-22 14:54:40 -04:00
// Clear existing chapters
foreach (Transform child in chapterContainer)
{
Destroy(child.gameObject);
}
2025-06-06 10:14:55 -04:00
foreach (var chapter in ChapterSelectionManager.instance.chapters)
{
ChapterSelectionUI item = Instantiate(chapterSelectionUIPrefab, chapterContainer).GetComponent<ChapterSelectionUI>();
item.Initialize(chapter);
2025-06-14 14:42:49 -04:00
item.chapterName = chapter.chapterName;
2025-06-06 10:14:55 -04:00
}
}
}
}