Open a new scene when all scene editors are closed

This commit is contained in:
antopilo
2025-02-02 12:16:29 -05:00
parent 41c05f52a1
commit 3635e1195c
2 changed files with 12 additions and 2 deletions

View File

@@ -2138,9 +2138,19 @@ namespace Nuake {
if (auto window = sceneEditors[i]; window->GetWindowName() == windowName)
{
sceneEditors.erase(std::begin(sceneEditors) + i);
return;
}
}
// When closing all editors, it should open a new scene
if (sceneEditors.empty())
{
auto newScene = CreateRef<Scene>();
newScene->SetName("New Scene");
Ref<SceneEditorWindow> sceneEditor = CreateRef<SceneEditorWindow>(newScene);
sceneEditor->DockTo(SceneEditorDockspaceNodeID);
sceneEditors.push_back(sceneEditor);
}
}
void EditorInterface::OpenPrefabWindow(const std::string& prefabPath)

View File

@@ -34,7 +34,7 @@ void SceneEditorWindow::Update(float ts)
void SceneEditorWindow::Draw()
{
const std::string sceneName = editorContext.GetScene()->Path;
std::string sceneName = editorContext.GetScene()->Path.empty() ? "New Scene" : editorContext.GetScene()->Path;
ImGuiID editorDockspaceId = ImGui::GetID("SceneEditorDockSpace");
if (!layoutInitialized)