96 lines
2.4 KiB
C#
96 lines
2.4 KiB
C#
using Assets.WasapiAudio.Scripts.Unity;
|
|
using System.Collections.Generic;
|
|
using System.Collections;
|
|
using UnityEditor;
|
|
using UnityEngine.SceneManagement;
|
|
using UnityEngine.UI;
|
|
using UnityEngine.VFX;
|
|
using UnityEngine;
|
|
|
|
|
|
public class Loader : MonoBehaviour {
|
|
public KeyCode NextButton = KeyCode.Space;
|
|
public KeyCode PrevButton = KeyCode.Return;
|
|
public KeyCode MenuButton = KeyCode.Escape;
|
|
|
|
public GameObject menu;
|
|
public Text currentVis;
|
|
public Canvas vfxMenu;
|
|
|
|
private static bool menuVisible;
|
|
private Scene scene;
|
|
|
|
void Awake() {
|
|
ToggleMenu(menuVisible);
|
|
}
|
|
|
|
void Start() {
|
|
scene = SceneManager.GetActiveScene();
|
|
currentVis.text = scene.name;
|
|
// Debug.Log("Active Scene name is: " + scene.name + "\nActive Scene index: " + scene.buildIndex);
|
|
}
|
|
|
|
void Update() {
|
|
if (Input.GetKeyDown(NextButton)) {
|
|
NextScene();
|
|
}
|
|
|
|
if (Input.GetKeyDown(NextButton)) {
|
|
PrevScene();
|
|
}
|
|
|
|
if (Input.GetKeyDown(MenuButton)) {
|
|
ToggleMenu(!menuVisible);
|
|
}
|
|
}
|
|
|
|
void VfxMenuVisible(bool v) {
|
|
if (vfxMenu) vfxMenu.enabled = v;
|
|
}
|
|
|
|
void ToggleMenu(bool visible) {
|
|
if (visible) {
|
|
menu.GetComponent<Canvas>().enabled = true;
|
|
VfxMenuVisible(true);
|
|
} else {
|
|
menu.GetComponent<Canvas>().enabled = false;
|
|
VfxMenuVisible(false);
|
|
}
|
|
|
|
menuVisible = visible;
|
|
}
|
|
|
|
public void NextScene() {
|
|
int current = scene.buildIndex;
|
|
int next = (current + 1) % (SceneManager.sceneCountInBuildSettings);
|
|
if (next != current) LoadScene(next);
|
|
}
|
|
|
|
public void PrevScene() {
|
|
int current = scene.buildIndex;
|
|
int prev = (current - 1);
|
|
if (prev < 0) prev = SceneManager.sceneCountInBuildSettings - 1;
|
|
if (prev != current) LoadScene(prev);
|
|
}
|
|
|
|
public void LoadScene(int i) {
|
|
SceneManager.LoadScene(i);
|
|
}
|
|
|
|
public void Quit() {
|
|
EditorApplication.isPlaying = false;
|
|
Application.Quit();
|
|
}
|
|
|
|
// IEnumerator LoadScene(int i) {
|
|
// AsyncOperation asyncLoad = SceneManager.LoadSceneAsync(i);
|
|
|
|
// // Wait until the asynchronous scene fully loads
|
|
// while (!asyncLoad.isDone)
|
|
// {
|
|
// yield return null;
|
|
// }
|
|
// }
|
|
|
|
}
|