Version: 2019.4
public static SceneManagement.Scene LoadSceneInPlayMode (string path, SceneManagement.LoadSceneParameters parameters);

パラメーター

pathPath to Scene to load.
parametersParameters used to load the Scene SceneManagement.LoadSceneParameters.

戻り値

Scene Scene that is loading.

説明

This method allows you to load a Scene during playmode in the editor, without requiring the Scene to be included in the Build Settings Scene list.

The use case for this is to emulate Asset bundles while loading scenes in play mode in the editor. When including a scene in an asset bundle, you don't add the scene to build settings. This means you can't load the scene during play mode using the normal LoadScene method. Using this method instead of LoadScene allows you to load the scene during play mode without requiring it to be in the Build Settings scene list. This means your code needs to detect whether the game is running in the editor or not, and use this method (LoadSceneInPlayMode) when in the editor, and LoadScene when in the built version. The use case for this is to emulate Asset bundles while loading Scenes in play mode in the editor. When including a Scene in an asset bundle, you don't add the Scene to build settings. This means you can't load the Scene during play mode using the normal LoadScene method. Using this method instead of LoadScene allows you to load the Scene during play mode without requiring it to be in the Build Settings Scene list. This means your code needs to detect whether the game is running in the editor or not, and use this method (LoadSceneInPlayMode) when in the editor, and LoadScene when in the built version.

Note that this function behaves the same as SceneManager.LoadScene meaning that the load does not happen immedately but is guarantee to complete in the next frame. This behavior also means that the Scene that is returned has its state set to Loading.

Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961