- |
-
-
+**Common mistake vs. fixes:**
+```cpp
ImGui::Begin("Incorrect!");
ImGui::DragFloat2("My value", &objects[0]->pos.x);
-ImGui::DragFloat2("My value", &objects[1]->pos.x);
-ImGui::DragFloat2("My value", &objects[2]->pos.x);
+ImGui::DragFloat2("My value", &objects[1]->pos.x); // ID collision!
+ImGui::DragFloat2("My value", &objects[2]->pos.x); // ID collision!
ImGui::End();
-
+
ImGui::Begin("Correct!");
ImGui::DragFloat2("My value", &objects[0]->pos.x);
ImGui::DragFloat2("My value##2", &objects[1]->pos.x);
ImGui::DragFloat2("My value##3", &objects[2]->pos.x);
ImGui::End();
-
+
ImGui::Begin("Also Correct!");
for (int n = 0; n < 3; n++)
{
@@ -302,628 +298,426 @@ for (int n = 0; n < 3; n++)
ImGui::PopID();
}
ImGui::End();
-
- |
-
-