GetSceneByPath() public static method

Searches all scenes added to the SceneManager for a scene that has the given asset path.

public static GetSceneByPath ( string scenePath ) : Scene
scenePath string Path of the scene. Should be relative to the project folder. Like: "AssetsMyScenesMyScene.unity".
return Scene
示例#1
0
 public static Scene GetSceneByPath(string scenePath)
 {
     scenePath = getBuildSettingsScenePath(scenePath);
     return(SceneManager.GetSceneByPath(scenePath));
 }
 /// <summary>
 /// 设置活动场景
 /// </summary>
 /// <param name="sceneAssetName"></param>
 /// <returns></returns>
 public bool SetActiveScene(string sceneAssetName)
 {
     return(SceneManager.SetActiveScene(SceneManager.GetSceneByPath(sceneAssetName)));
 }