diff --git a/TSE_Core/src/elements/Transformable.cpp b/TSE_Core/src/elements/Transformable.cpp index c37916d..aa6ff12 100644 --- a/TSE_Core/src/elements/Transformable.cpp +++ b/TSE_Core/src/elements/Transformable.cpp @@ -34,6 +34,10 @@ namespace TSE objectEntries[id] = this; } + Transformable::~Transformable() + { + } + Vector3 Transformable::forward() const { return Vector3::Normalize(GetGlobalMatrix() * Vector3::forward - GetGlobalMatrix() * Vector3::zero); @@ -368,12 +372,15 @@ namespace TSE if(!onlyThis) for(auto child : t->children) { - HardDelete(child); + HardDelete(child, onlyThis); } //deleting atteched scripts for (auto& [_, script] : t->components) + { delete script; + } + t->components.clear(); //deleting self Delete(t); diff --git a/TSE_Core/src/elements/Transformable.hpp b/TSE_Core/src/elements/Transformable.hpp index 089eb5c..fbc8990 100644 --- a/TSE_Core/src/elements/Transformable.hpp +++ b/TSE_Core/src/elements/Transformable.hpp @@ -36,7 +36,7 @@ namespace TSE Transformable(uuids::uuid id); Transformable(const string& name); Transformable(const string& name, uuids::uuid id); - ~Transformable() = default; + ~Transformable(); Vector3 forward() const; Vector3 right() const; diff --git a/TSE_Editor/src/UI/windows/HirearchieView.cpp b/TSE_Editor/src/UI/windows/HirearchieView.cpp index c898665..fd6a767 100644 --- a/TSE_Editor/src/UI/windows/HirearchieView.cpp +++ b/TSE_Editor/src/UI/windows/HirearchieView.cpp @@ -123,6 +123,8 @@ void TSE::EDITOR::HirearchieView::MenuBar() ImGui::EndMenuBar(); } +bool selectedFound = false; + void TSE::EDITOR::HirearchieView::DisplayLayer(Layer *l) { ImGui::Indent(20.0f); @@ -180,10 +182,15 @@ void TSE::EDITOR::HirearchieView::DisplayLayer(Layer *l) } if(collapseOpen) { + selectedFound = false; for(int i = 0; i < l->GetAllObjects().size(); i++) { DisplayObj(l->GetAllObjects()[i], l); } + if(!selectedFound && PropertiesView::GetCurrentInspectableType() == InspectableType::Transformable) + { + PropertiesView::ForceClearInspectorElement(); + } } ImGui::Unindent(20.0f); } @@ -198,8 +205,10 @@ void TSE::EDITOR::HirearchieView::DisplayObj(Transformable *t, Layer *l) if(selected == t->id) { flags |= ImGuiTreeNodeFlags_Selected; + selectedFound = true; } - bool open = ImGui::TreeNodeEx((t->GetName() + "##" + to_string(t->id)).c_str(), flags); + string name = t->GetName() + "##" + to_string(t->id); + bool open = ImGui::TreeNodeEx((name).c_str(), flags); if(ImGui::BeginPopupContextItem()) { bool disabled = false; diff --git a/TSE_Editor/src/UI/windows/PropertiesView.cpp b/TSE_Editor/src/UI/windows/PropertiesView.cpp index 041ca57..d6a8d91 100644 --- a/TSE_Editor/src/UI/windows/PropertiesView.cpp +++ b/TSE_Editor/src/UI/windows/PropertiesView.cpp @@ -30,6 +30,11 @@ void TSE::EDITOR::PropertiesView::MenuBar() ImGui::EndMenuBar(); } +TSE::EDITOR::InspectableType TSE::EDITOR::PropertiesView::GetCurrentInspectableType() +{ + return currentlyInspecting.type; +} + void TSE::EDITOR::PropertiesView::SetInspectorElement(InspectableType type, void *element) { if(!locked) diff --git a/TSE_Editor/src/UI/windows/PropertiesView.hpp b/TSE_Editor/src/UI/windows/PropertiesView.hpp index 372d5b2..8c22ab8 100644 --- a/TSE_Editor/src/UI/windows/PropertiesView.hpp +++ b/TSE_Editor/src/UI/windows/PropertiesView.hpp @@ -17,6 +17,7 @@ namespace TSE::EDITOR void Define() override; void MenuBar(); + static InspectableType GetCurrentInspectableType(); static void SetInspectorElement(InspectableType type, void* element); static void ClearInspectorElement(); static void ForceClearInspectorElement();