#pragma once #include #include "ComponentPanel.h" #include "ModelResourceInspector.h" #include #include #include #include class MeshPanel : ComponentPanel { private: Scope _modelInspector; bool _expanded = false; public: MeshPanel() { CreateScope(); } void Draw(Nuake::Entity entity) override { using namespace Nuake; if (!entity.HasComponent()) return; ModelComponent& component = entity.GetComponent(); BeginComponentTable(MESH, ModelComponent); { ImGui::Text("Model"); ImGui::TableNextColumn(); std::string label = std::to_string(component.ModelResource->ID); if (ImGui::Button(label.c_str(), ImVec2(ImGui::GetContentRegionAvail().x, 0))) { if (!_expanded) { _modelInspector = CreateScope(component.ModelResource); } _expanded = !_expanded; } if (_expanded) { _modelInspector->Draw(); } if (ImGui::BeginDragDropTarget()) { if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload("_Model")) { char* file = (char*)payload->Data; std::string fullPath = std::string(file, 256); fullPath = Nuake::FileSystem::AbsoluteToRelative(fullPath); if (Nuake::String::EndsWith(fullPath, ".model")) { } else { component.ModelPath = fullPath; component.LoadModel(); } } ImGui::EndDragDropTarget(); } ImGui::TableNextColumn(); ComponentTableReset(component.ModelPath, ""); } EndComponentTable(); } };