liuzhiwei
2020-12-24 45f7442afa3b25cc79c76898224e48d6aed1a2ee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using UnityEngine;
using UnityEngine.SceneManagement;
 
namespace TowerDefense.UI
{
    /// <summary>
    /// Simple component to load scenes by name
    /// </summary>
    public class SceneLoader : MonoBehaviour
    {
        /// <summary>
        /// Name of the scene to load
        /// </summary>
        public string sceneToLoadName = "LevelSelect";
 
        /// <summary>
        /// Loads the scene from <see cref="sceneToLoadName" />
        /// if a scene with that name exists
        /// </summary>
        public void LoadScene()
        {
            SceneManager.LoadScene(sceneToLoadName);
        }
 
        /// <summary>
        /// 整体退出游戏
        /// </summary>
        public void quitGame()
        {
            Application.Quit();
        }
 
        /// <summary>
        /// Restarts the current scene
        /// </summary>
        public void RestartCurrentScene()
        {
            Scene activeScene = SceneManager.GetActiveScene();
            SceneManager.LoadScene(activeScene.name);
        }
    }
}