class MeshComponentRender { Entity entity; MeshComponent meshComponent; MeshComponentRender(Entity _entity) { entity = _entity; meshComponent = entity.getMeshComponent(); } void render() { if (!entity.hasMeshComponent()) return; if (meshComponent.hasMesh) { UI::drawIcon("object3d.png", 32); } else { UI::drawIcon("empty.png", 32); } UI::dragDropTarget("MESH", AnyCallback(this.setMesh)); if (meshComponent.hasMesh) { UI::sameline(); UI::space(); UI::sameline(); UI::titleCenterY(meshComponent.meshResource.name, 32); UI::dragDropTarget("MESH", AnyCallback(this.setMesh)); } UI::space(20, 20); if (UI::button("Clear")) { meshComponent.clear(); } UI::sameline(); UI::space(10, 20); UI::sameline(); if (meshComponent.hasMesh) { meshComponent.isActive = UI::checkbox("Active", meshComponent.isActive); } else { UI::checkboxDisabled("Active", meshComponent.isActive); } } void setMesh(any@ mesh_data) { string mesh; mesh_data.retrieve(mesh); meshComponent.meshResource = Resource::loadGPUMesh(mesh); } void remove() { if (UI::menuItem("Remove")) { entity.removeMeshComponent(); } } }