Fix editor scene persistence and XC scene workflow
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user