I have this piece of code, I need to automatically be able to modify values of their components. My components all derive from Component class, e.g. MeshComponent : Component, TransformComponent : Component.
I found that when casting component to (MeshComponent*) and then doing set_value works, but how would I automatically convert this to the correct type? I have tried using var.convert(type); but that just returns 0, is it because type is not a pointer?
for (Component* component : selectedEntity->GetAllComponents()) {
const rttr::type type = rttr::type::get_by_name(component->GetName());
rttr::variant var = component;
for (rttr::property& prop : type.get_properties()) {
if (prop.get_type() == rttr::type::get<int>()) {
int value = prop.get_value(var).to_int();
ImGui::InputInt(prop.get_name().c_str(), &value);
bool success = prop.set_value(var, value);
}
}
}
I have this piece of code, I need to automatically be able to modify values of their components. My components all derive from Component class, e.g. MeshComponent : Component, TransformComponent : Component.
I found that when casting component to (MeshComponent*) and then doing set_value works, but how would I automatically convert this to the correct type? I have tried using
var.convert(type);
but that just returns 0, is it because type is not a pointer?