已加载场景数。
返回当前已加载场景数。其中不包括当前正在加载或卸载的场景。如需查看场景总数,请参阅 SceneManager.sceneCount。
using UnityEngine; using UnityEngine.SceneManagement; using UnityEditor;
public class Example { // adds a custom menu item which displays the number of open Scenes in a Dialogue Box [MenuItem("SceneExample/Number Of Scenes")] public static void NumberOfScenes() { EditorUtility.DisplayDialog("Number of loaded Scenes:", SceneManager.loadedSceneCount.ToString(), "OK"); } }