using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class SceneSwitcher : MonoBehaviour { // make singleton public static SceneSwitcher Instance { get; private set; } private void Awake() { SetInstance(); } private void OnValidate() { SetInstance(); } private void SetInstance() { if (Instance == null) { Instance = this; } else { Debug.LogError("SceneSwitcher Instance already exists."); } } public void SwitchScene(int sceneIndex) { for (var i = 0; i < transform.childCount; i++) { transform.GetChild(i).gameObject.SetActive(i == sceneIndex); } } public List<(string name, int index)> GetScenes() { var scenes = new List<(string name, int index)>(); for (var i = 0; i < transform.childCount; i++) { var child = transform.GetChild(i); scenes.Add((child.name, i)); } return scenes; } }