using UnityEngine; using UnityEngine.SceneManagement; namespace TowerDefense.UI { /// /// Simple component to load scenes by name /// public class SceneLoader : MonoBehaviour { /// /// Name of the scene to load /// public string sceneToLoadName = "LevelSelect"; /// /// Loads the scene from /// if a scene with that name exists /// public void LoadScene() { SceneManager.LoadScene(sceneToLoadName); } /// /// 整体退出游戏 /// public void quitGame() { Application.Quit(); } /// /// Restarts the current scene /// public void RestartCurrentScene() { Scene activeScene = SceneManager.GetActiveScene(); SceneManager.LoadScene(activeScene.name); } } }