Fix editor scene persistence and XC scene workflow

This commit is contained in:
2026-03-26 01:26:26 +08:00
parent 39edb0b497
commit 0651666d8c
35 changed files with 1958 additions and 256 deletions

View File

@@ -8,6 +8,7 @@
#include "panels/ProjectPanel.h"
#include "Core/IEditorContext.h"
#include "Core/EditorContext.h"
#include <filesystem>
#include <imgui.h>
#include <imgui_internal.h>
@@ -41,6 +42,10 @@ void EditorLayer::onAttach() {
m_consolePanel->SetContext(m_context.get());
m_projectPanel->SetContext(m_context.get());
m_projectPanel->Initialize(m_context->GetProjectPath());
m_context->GetSceneManager().LoadStartupScene(m_context->GetProjectPath());
m_context->GetProjectManager().RefreshCurrentFolder();
m_menuBar->OnAttach();
m_hierarchyPanel->OnAttach();
m_sceneViewPanel->OnAttach();
@@ -48,11 +53,18 @@ void EditorLayer::onAttach() {
m_inspectorPanel->OnAttach();
m_consolePanel->OnAttach();
m_projectPanel->OnAttach();
m_projectPanel->Initialize(m_context->GetProjectPath());
}
void EditorLayer::onDetach() {
auto& sceneManager = m_context->GetSceneManager();
if (sceneManager.HasActiveScene() && sceneManager.IsSceneDirty()) {
if (!sceneManager.SaveScene()) {
const std::string fallbackPath =
(std::filesystem::path(m_context->GetProjectPath()) / "Assets" / "Scenes" / "Main.xc").string();
sceneManager.SaveSceneAs(fallbackPath);
}
}
m_menuBar->OnDetach();
m_hierarchyPanel->OnDetach();
m_sceneViewPanel->OnDetach();