62 lines
1.4 KiB
ActionScript

void renderMeshComponent(any@ data) {
Entity entity;
data.retrieve(entity);
if (!entity.hasMeshComponent())
return;
MeshComponent meshComponent = entity.getMeshComponent();
if (meshComponent.hasMesh) {
UI::drawIcon("object3d", 32);
} else {
UI::drawIcon("empty", 32);
}
UI::dragDropTarget("MESH", any(meshComponent), setMeshComponentMesh);
if (meshComponent.hasMesh) {
UI::sameline();
UI::space();
UI::sameline();
UI::titleCenterY(meshComponent.getMesh(), 32);
UI::dragDropTarget("MESH", any(meshComponent), setMeshComponentMesh);
}
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 setMeshComponentMesh(any@ meshComponent_data, any@ mesh_data) {
string mesh;
mesh_data.retrieve(mesh);
MeshComponent meshComponent;
meshComponent_data.retrieve(meshComponent);
meshComponent.setMesh(mesh);
}
void removeMeshComponent(any@ entity) {
Entity ent;
entity.retrieve(ent);
if (UI::menuItem("Remove")) {
ent.removeMeshComponent();
}
}