Closed VagueLobster closed 2 years ago
Hey, I would suggest calling NewScene() at this point, replacing this block in OnAttach()
:
m_EditorScene = CreateRef<Scene>();
m_ActiveScene = m_EditorScene;
m_SceneHierarchyPanel.SetContext(m_ActiveScene);
with: NewScene();
This would however need a improvement/refactor of NewScene()
that would look like:
void EditorLayer::NewScene()
{
if (m_SceneState != SceneState::Edit)
return;
m_EditorScene = CreateRef<Scene>();
m_EditorScene->OnViewportResize((uint32_t)m_ViewportSize.x, (uint32_t)m_ViewportSize.y);
m_SceneHierarchyPanel.SetContext(m_EditorScene);
m_ActiveScene = m_EditorScene;
m_EditorScenePath = std::filesystem::path();
}
This also fixes the following other issues:
m_EditorScene
gets copied to m_ActiveScene
, causing loss off all progress.I currently have this fix on my Hazel fork, so I could just open a PR to your fork(?) (would need some conflict resolving) or should I rather open a new PR?
Hey, I would suggest calling NewScene() at this point, replacing this block in
OnAttach()
:m_EditorScene = CreateRef<Scene>(); m_ActiveScene = m_EditorScene; m_SceneHierarchyPanel.SetContext(m_ActiveScene);
with:
NewScene();
This would however need a improvement/refactor of
NewScene()
that would look like:void EditorLayer::NewScene() { if (m_SceneState != SceneState::Edit) return; m_EditorScene = CreateRef<Scene>(); m_EditorScene->OnViewportResize((uint32_t)m_ViewportSize.x, (uint32_t)m_ViewportSize.y); m_SceneHierarchyPanel.SetContext(m_EditorScene); m_ActiveScene = m_EditorScene; m_EditorScenePath = std::filesystem::path(); }
This also fixes the following other issues:
- When you try to open a new scene while playing/simulating, Hazelnut crashes.
- When you start Hazelnut, open a new scene, add entities, press play/simulate, the empty
m_EditorScene
gets copied tom_ActiveScene
, causing loss off all progress.I currently have this fix on my Hazel fork, so I could just open a PR to your fork(?) (would need some conflict resolving) or should I rather open a new PR?
Erhm, i think it's better to just wait and see what @TheCherno has to say about this 🙂
Describe the issue (if no issue has been made)
Currently with the code used in Hazel 2D, and when launching Hazel 2D, you can't get the "Create Empty Entity" to pop up.
This bug is ONLY happening when you haven't loaded a scene OR created a new scene!
Proposed fix _(Make sure you've read [on how to contribute])
By adding:
m_SceneHierarchyPanel.SetContext(m_ActiveScene);
afterm_ActiveScene = m_EditorScene;
insideOnAttach()
inEditorLayer.cpp
right-clicking to display the menu works again!Steps to reproduce the bug: 1: open up Hazel 2D. 2: Move mouse cursor over to the Scene hierarchy. 3: Right-click and see that the "Create Empty Entity" won't pop up.