using System; using DanielLochner.Assets.SimpleScrollSnap; using System.Collections; using System.Collections.Generic; using UnityEngine; namespace Beyond { public class PanelSwitcher : MonoBehaviour { public SimpleScrollSnap snap; private int latestPanelIndex = 0; private delegate void EnableCallback(int index); private Action enableCallback; private void OnEnable() { enableCallback?.Invoke(); enableCallback = null; } public void SwapToNextPanel() { snap.GoToNextPanel(); } public void SwapToLastPanel() { latestPanelIndex = snap.CurrentPanel; snap.GoToPanel(snap.Panels.Length - 1); } public void GoBackToLatestPanel() { snap.GoToPanel(latestPanelIndex); } public void SetPanelToIndex(int index) { if (gameObject.activeInHierarchy) { snap.GoToPanel(index); } else { enableCallback += () => snap.GoToPanel(index); } } } }