-
-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Closed
Labels
label/id and id stackimplicit identifiers, pushid(), id stackimplicit identifiers, pushid(), id stack
Description
I'm trying to create a UI component for every object that I have on an array so I could change the values of them, and I'm doing this by a loop:
for (int i = 0; i < objs_array->size(); i++) {
obj *current_obj = &objs_array->at(i);
ImGui::PushID(current_obj->id.c_str());
ImGui::Begin(current_obj->id.c_str());
std::string label_x = "Translation x " + current_obj->id;
std::string label_y = "Translation y " + current_obj->id;
std::string label_z = "Translation z " + current_obj->id;
ImGui::SliderFloat(label_x.c_str(), ¤t_obj->translation.x,-50.0f, 50.0f);
ImGui::SliderFloat(label_y.c_str(), ¤t_obj->translation.y,-50.0f, 50.0f);
ImGui::SliderFloat(label_y.c_str(), ¤t_obj->translation.z,-50.0f, 50.0f);
ImGui::End();
ImGui::PopID();
}
Just a small example but the structure is pretty much the same. With only one component everything works fine, however with multiple objects the last component created is changing the values of the other objects in the array and the remaining created components get stuck on negative zeroes or with huge random numbers.
Am I missinterpreting something or is there some other way to do it? I've tried many solutions to this but any of them seems to work.
Any help or pointer to my stupidity would be appreciated.
Thanks.
Metadata
Metadata
Assignees
Labels
label/id and id stackimplicit identifiers, pushid(), id stackimplicit identifiers, pushid(), id stack