Method group is Obsolete

SceneManager.UnloadScene

切换到手册
Obsolete public static bool UnloadScene (int sceneBuildIndex);
Obsolete public static bool UnloadScene (string sceneName);
Obsolete public static bool UnloadScene (SceneManagement.Scene scene);

参数

sceneBuildIndexBuild Settings 中要卸载场景的索引。
sceneName要卸载的场景的名称或路径。
scene要卸载的场景。

返回

bool 如果场景已卸载,则返回 true。

描述

销毁所有与给定场景关联的游戏对象,并将场景从 SceneManager 中移除。

注意:不建议使用此函数,可以改用 UnloadSceneAsync

警告:无法在不同的物理和可见性回调(如 OnTriggerEnter 或 OnBecameVisible)过程中调用此函数,因此不建议使用。

The given Scene name can either be the full Scene path, the path shown in the Build Settings window or just the Scene name. If only the Scene name is given this will load the first Scene in the list that matches. If you have multiple Scenes with same name but different paths, you should use the full Scene path. Examples of supported formats:
"Scene1"
"Scene2"
"Scenes/Scene3"
"Scenes/Others/Scene3"
"Assets/scenes/others/scene3.unity"

Note: sceneName is case insensitive.
Note: Assets are currently not unloaded, in order to free up asset memory call Resources.UnloadAllUnusedAssets.