043f777207
quit buttons in pause menus are fixed. also the persistent data objects were not deleting themselves if another copy exists, so that's been fixed
58 lines
1.6 KiB
C#
58 lines
1.6 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
using TMPro;
|
|
|
|
public class DebugSceneSwitcher : MonoBehaviour
|
|
{
|
|
public static DebugSceneSwitcher Instance = null;
|
|
|
|
public bool showDropdown;
|
|
|
|
void Awake()
|
|
{
|
|
if (Instance == null) {
|
|
Instance = this;
|
|
} else {
|
|
Destroy(this.gameObject);
|
|
return;
|
|
}
|
|
// Keep the object around when we switch scenes
|
|
DontDestroyOnLoad(this.gameObject);
|
|
CreateDropdownOptions();
|
|
}
|
|
|
|
void CreateDropdownOptions()
|
|
{
|
|
TMP_Dropdown sceneDropdown = GameObject.Find("SceneSwitcherDropdown").GetComponent<TMP_Dropdown>();
|
|
if (showDropdown) {
|
|
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);
|
|
}
|
|
} else {
|
|
sceneDropdown.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|
|
public void ChangeScene(int index)
|
|
{
|
|
// print(index);
|
|
SceneController.Instance.LoadChosenScene(index);
|
|
this.gameObject.SetActive(false);
|
|
}
|
|
|
|
public void ChangeSceneByName(string name) {
|
|
SceneController.Instance.LoadSceneByName(name);
|
|
this.gameObject.SetActive(false);
|
|
}
|
|
}
|