65 lines
1.7 KiB
ActionScript
65 lines
1.7 KiB
ActionScript
class MeshComponentRender {
|
|
Entity entity;
|
|
MeshComponent meshComponent;
|
|
|
|
MeshComponentRender(Entity _entity) {
|
|
entity = _entity;
|
|
meshComponent = entity.getComponent<MeshComponent>();
|
|
}
|
|
|
|
void render() {
|
|
if (!entity.hasComponent<MeshComponent>())
|
|
return;
|
|
|
|
// Mesh icon
|
|
if (meshComponent.hasMesh) {
|
|
ImGui::drawIcon(StudioAPI::loadIcon("object3d.png"), 32);
|
|
} else {
|
|
ImGui::drawIcon(StudioAPI::loadIcon("empty.png"), 32);
|
|
}
|
|
|
|
ImGui::dragDropTarget("MESH", ReciverFunction(this.setMesh));
|
|
|
|
if (meshComponent.hasMesh) {
|
|
ImGui::sameline();
|
|
ImGui::space();
|
|
ImGui::sameline();
|
|
|
|
GPUMesh mesh = meshComponent.get_meshResource();
|
|
ImGui::titleCenterY(mesh.name, 32);
|
|
ImGui::dragDropTarget("MESH", ReciverFunction(this.setMesh));
|
|
}
|
|
|
|
ImGui::space(0, 20);
|
|
|
|
if (ImGui::button("Clear")) {
|
|
meshComponent.clear();
|
|
}
|
|
|
|
ImGui::sameline();
|
|
ImGui::space(0, 20);
|
|
ImGui::sameline();
|
|
|
|
bool active = meshComponent.get_isActive();
|
|
if (meshComponent.get_hasMesh()) {
|
|
active = ImGui::checkbox("Active", active);
|
|
meshComponent.set_isActive(active);
|
|
} else {
|
|
ImGui::checkboxDisabled("Active", active);
|
|
}
|
|
}
|
|
|
|
void setMesh(any@ meshData) {
|
|
GPUMesh mesh;
|
|
if (meshData.retrieve(mesh)) {
|
|
meshComponent.meshResource = mesh;
|
|
}
|
|
}
|
|
|
|
void remove() {
|
|
if (ImGui::menuItem("Remove")) {
|
|
entity.removeComponent<MeshComponent>();
|
|
}
|
|
}
|
|
}
|