class MeshComponentRender { Entity entity; MeshComponent meshComponent; MeshComponentRender(Entity _entity) { entity = _entity; meshComponent = entity.getComponent(); } void render() { if (!entity.hasComponent()) return; ImGui::columns(2); ImGui::text("Mesh "); ImGui::nextColumn(); if (meshComponent.hasMesh) { ImGui::buttonExpanded(meshComponent.meshResource.getResourceId().name); } else { ImGui::buttonExpanded(""); } ImGui::dragDropTarget("MESH", ReciverFunction(this.setMesh)); ImGui::space(0, 1); ImGui::nextColumn(); ImGui::text("Shader "); ImGui::nextColumn(); if (meshComponent.hasShader) { ImGui::buttonExpanded(meshComponent.shader.getResourceId().name); } else { ImGui::buttonExpanded(""); } ImGui::dragDropTarget("SHADER", ReciverFunction(this.setShader)); ImGui::space(0, 1); ImGui::nextColumn(); ImGui::text("Texture "); ImGui::nextColumn(); if (meshComponent.hasTexture) { ImGui::buttonExpanded(meshComponent.texture.getResourceId().name); } else { ImGui::buttonExpanded(""); } ImGui::dragDropTarget("TEXTURE", ReciverFunction(this.setTexture)); ImGui::endColumns(); // Mesh icon /* if (meshComponent.hasMesh) { FrameBuffer frameBuffer = Previewer::getMeshPreview(meshComponent.meshResource); ImGui::drawFrameBufferCentered(frameBuffer, 128, 128); } else { ImGui::drawIconCentered(StudioAPI::loadIcon("empty.png"), 128); } */ } void setMesh(any@ meshData) { GPUMesh mesh; if (meshData.retrieve(mesh)) { meshComponent.meshResource = mesh; } } void setShader(any@ meshData) { Shader shader; if (meshData.retrieve(shader)) { meshComponent.shader = shader; } } void setTexture(any@ meshData) { Texture texture; if (meshData.retrieve(texture)) { meshComponent.texture = texture; } } void remove() { if (ImGui::menuItem("Remove")) { entity.removeComponent(); } if (ImGui::menuItem("Clear")) { meshComponent.clear(); } } }