refactor
This commit is contained in:
@@ -52,7 +52,7 @@ namespace RebootKitEditor.RebootWindow {
|
||||
}
|
||||
};
|
||||
root.Add(label);
|
||||
|
||||
|
||||
Button openButton = new(() => OpenWorldScenes(worldConfigAsset)) {
|
||||
text = "Open",
|
||||
style = {
|
||||
@@ -76,14 +76,16 @@ namespace RebootKitEditor.RebootWindow {
|
||||
return;
|
||||
}
|
||||
|
||||
EditorSceneManager.SaveOpenScenes();
|
||||
|
||||
// Load first scene from build settings
|
||||
string mainScenePath = SceneManager.GetSceneByBuildIndex(RConsts.k_MainSceneBuildIndex).path;
|
||||
string mainScenePath = GetScenePathByBuildIndex(RConsts.k_MainSceneBuildIndex);
|
||||
if (mainScenePath == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
EditorSceneManager.OpenScene(mainScenePath, OpenSceneMode.Single);
|
||||
|
||||
// Load world scene
|
||||
string worldScenePath = AssetDatabase.GetAssetPath(worldConfigAsset.Config.mainScene.editorAsset);
|
||||
string worldScenePath = AssetDatabase.GUIDToAssetPath(worldConfigAsset.Config.mainScene.AssetGUID);
|
||||
if (string.IsNullOrEmpty(worldScenePath)) {
|
||||
Debug.LogError($"WorldConfigAsset {worldConfigAsset.name} has invalid main scene path");
|
||||
return;
|
||||
@@ -91,5 +93,14 @@ namespace RebootKitEditor.RebootWindow {
|
||||
|
||||
SceneManager.SetActiveScene(EditorSceneManager.OpenScene(worldScenePath, OpenSceneMode.Additive));
|
||||
}
|
||||
|
||||
static string GetScenePathByBuildIndex(int buildIndex) {
|
||||
if (buildIndex < 0 || buildIndex >= EditorBuildSettings.scenes.Length) {
|
||||
Debug.LogError($"Build index {buildIndex} out of range. Total scenes in build: {EditorBuildSettings.scenes.Length}");
|
||||
return null;
|
||||
}
|
||||
|
||||
return EditorBuildSettings.scenes[buildIndex].path;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user