5a7ce8fb2b
This doesnt' change any of the logic, but simplifies a lot of the main game loop code. Many things still rely on the singleton class, but shouldn't so this will be fixed in a later commit
39 lines
1.1 KiB
C#
39 lines
1.1 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
using TMPro;
|
|
|
|
public class DebugSceneSwitcher : MonoBehaviour
|
|
{
|
|
void Awake()
|
|
{
|
|
// Keep the object around when we switch scenes
|
|
DontDestroyOnLoad(this.gameObject);
|
|
CreateDropdownOptions();
|
|
}
|
|
|
|
void CreateDropdownOptions()
|
|
{
|
|
TMP_Dropdown sceneDropdown = GameObject.Find("SceneSwitcherDropdown").GetComponent<TMP_Dropdown>();
|
|
if (sceneDropdown.options.Count == 0)
|
|
{
|
|
List<string> sceneNames = new List<string>();
|
|
for (int i = 0; i < SceneManager.sceneCountInBuildSettings; i++)
|
|
{
|
|
string newName = System.IO.Path.GetFileNameWithoutExtension(SceneUtility.GetScenePathByBuildIndex(i));
|
|
print(newName);
|
|
sceneNames.Add(newName);
|
|
}
|
|
sceneDropdown.AddOptions(sceneNames);
|
|
}
|
|
}
|
|
|
|
public void ChangeScene(int index)
|
|
{
|
|
// print(index);
|
|
this.gameObject.SetActive(false);
|
|
SceneController.Instance.LoadChosenScene(index);
|
|
}
|
|
}
|