using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; namespace MyFrameworkPure { /// /// 场景管理工具 /// public class SceneManagerTool : MonoBehaviour { /// /// 获取所有场景名 /// /// public static string[] GetAllSceneName() { List sceneNameList = new List(); int count = SceneManager.sceneCountInBuildSettings; for (int i = 0; i < count; i++) { string path = SceneUtility.GetScenePathByBuildIndex(i); string sceneName = path.Substring(0, path.Length - 6).Substring(path.LastIndexOf('/') + 1); sceneNameList.Add(sceneName); } return sceneNameList.ToArray(); } /// /// 重新载入当前场景 /// public static void ReloadActiveScene() { SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex); } } }