Unique ids for entity nodes in the editor to prevent weird behaviour when multiple entities have the same name
This commit is contained in:
@@ -157,7 +157,7 @@ void EditorGUI::drawEntitiesRecursive(World* world, EntityID parent)
|
|||||||
auto entityChildren = world->GetEntityChildren();
|
auto entityChildren = world->GetEntityChildren();
|
||||||
auto range = entityChildren.equal_range(parent);
|
auto range = entityChildren.equal_range(parent);
|
||||||
for (auto it = range.first; it != range.second; it++) {
|
for (auto it = range.first; it != range.second; it++) {
|
||||||
if (EditorGUI::drawEntityNode(EntityWrapper(world, it->second))) {
|
if (drawEntityNode(EntityWrapper(world, it->second))) {
|
||||||
drawEntitiesRecursive(world, it->second);
|
drawEntitiesRecursive(world, it->second);
|
||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
@@ -217,6 +217,7 @@ bool EditorGUI::drawEntityNode(EntityWrapper entity)
|
|||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImGui::PushID(("EntityNode" + std::to_string(entity.ID)).c_str());
|
||||||
ImGui::SetNextTreeNodeOpened(true, ImGuiSetCond_Once);
|
ImGui::SetNextTreeNodeOpened(true, ImGuiSetCond_Once);
|
||||||
if (ImGui::TreeNode(formatEntityName(entity).c_str())) {
|
if (ImGui::TreeNode(formatEntityName(entity).c_str())) {
|
||||||
// Handle drop events for reparenting
|
// Handle drop events for reparenting
|
||||||
@@ -224,8 +225,10 @@ bool EditorGUI::drawEntityNode(EntityWrapper entity)
|
|||||||
entityChangeParent(m_CurrentlyDragging, entity);
|
entityChangeParent(m_CurrentlyDragging, entity);
|
||||||
m_CurrentlyDragging = EntityWrapper::Invalid;
|
m_CurrentlyDragging = EntityWrapper::Invalid;
|
||||||
}
|
}
|
||||||
|
ImGui::PopID();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
ImGui::PopID();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user