change: Switched the state controller and scene controller to a singleton class
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
This commit is contained in:
@@ -6,26 +6,21 @@ using TMPro;
|
||||
|
||||
public class DebugSceneSwitcher : MonoBehaviour
|
||||
{
|
||||
|
||||
void Awake() {
|
||||
if (!GameObject.Find("StateController").GetComponent<StateController>().inDebugMode) {
|
||||
Destroy(this.gameObject);
|
||||
}
|
||||
// check to see if a debug canvas already exists
|
||||
if (GameObject.FindGameObjectWithTag("DebugCanvas") != null) {
|
||||
Destroy(this.gameObject);
|
||||
} else { // if it doesn't, then this is the only one
|
||||
this.gameObject.tag = "DebugCanvas";
|
||||
}
|
||||
void Awake()
|
||||
{
|
||||
// Keep the object around when we switch scenes
|
||||
DontDestroyOnLoad(this.gameObject);
|
||||
CreateDropdownOptions();
|
||||
}
|
||||
|
||||
void CreateDropdownOptions() {
|
||||
void CreateDropdownOptions()
|
||||
{
|
||||
TMP_Dropdown sceneDropdown = GameObject.Find("SceneSwitcherDropdown").GetComponent<TMP_Dropdown>();
|
||||
if (sceneDropdown.options.Count == 0) {
|
||||
if (sceneDropdown.options.Count == 0)
|
||||
{
|
||||
List<string> sceneNames = new List<string>();
|
||||
for (int i = 0; i < SceneManager.sceneCountInBuildSettings; i++) {
|
||||
for (int i = 0; i < SceneManager.sceneCountInBuildSettings; i++)
|
||||
{
|
||||
string newName = System.IO.Path.GetFileNameWithoutExtension(SceneUtility.GetScenePathByBuildIndex(i));
|
||||
print(newName);
|
||||
sceneNames.Add(newName);
|
||||
@@ -34,9 +29,10 @@ public class DebugSceneSwitcher : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
public void ChangeScene(int index) {
|
||||
public void ChangeScene(int index)
|
||||
{
|
||||
// print(index);
|
||||
GameObject.FindGameObjectWithTag("SceneManager").GetComponent<SceneController>().LoadChosenScene(index);
|
||||
this.gameObject.SetActive(false);
|
||||
SceneController.Instance.LoadChosenScene(index);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user