using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; namespace Ichni.UI { public class ChapterSelectionUIPage : UIPageBase { public RectTransform chapterContainer; public HorizontalLayoutGroup containerLayoutGroup; public Button settingsButton; public GameObject chapterSelectionUIPrefab; protected override void Awake() { base.Awake(); fadeInStartAction = Initialize; settingsButton.onClick.AddListener(() => { FadeOut(); MenuManager.instance.settingsUIPage.FadeIn(); }); } private void Initialize() { // Clear existing chapters foreach (Transform child in chapterContainer) { Destroy(child.gameObject); } foreach (var chapter in ChapterSelectionManager.instance.chapters) { ChapterSelectionUI item = Instantiate(chapterSelectionUIPrefab, chapterContainer).GetComponent(); item.Initialize(chapter); item.chapterName = chapter.chapterName; } } } }