CedricGuillemet / ImGuizmo

Immediate mode 3D gizmo for scene editing and other controls based on Dear Imgui
MIT License
3.22k stars 907 forks source link

SetDrawList() not working after changing window name #257

Closed FatCatGames closed 2 years ago

FatCatGames commented 2 years ago

I want the name of my scene window to get a * at the end if there are any unsaved changes, but as soon as the name of the window is changed the gizmo stops being responsive, does not get highlighted when hovered, and can not be manipulated. Saving the scene changes the name back to what it was originally, but even that doesn't fix the problem, once it stops being responsive it doesn't go back.

std::string label = mySceneManager->GetCurrentScene()->GetName();
if (EditorCommandHandler::GetCommandCountSinceSave() > 0) label += "*";
ImGui::Begin((label + "###SceneWindow").c_str(), 0, ImGuiWindowFlags_NoScrollWithMouse | ImGuiWindowFlags_NoScrollbar);
ImGuizmo::SetDrawlist();
CedricGuillemet commented 2 years ago

Can you repro in the sample?

FatCatGames commented 2 years ago

Had a look at the demo and found the fix, I had to call this before beginning my scene window:

ImGui::Begin("gizmo", NULL, flags);
ImGuizmo::SetDrawlist(ImGui::GetWindowDrawList());
ImGui::End();

Then it works even if you change the name of the window!