From 0a6ee85e08da4756e2254cb95d2ed3044a5c4db9 Mon Sep 17 00:00:00 2001 From: ayuan9957 <107920784+ayuan9957@users.noreply.github.com> Date: Tue, 23 Jun 2026 14:29:51 +0800 Subject: [PATCH] feat(editor): show partial components in multi-select inspector --- .../Private/MetaCoreBuiltinEditorModule.cpp | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/Source/MetaCoreEditor/Private/MetaCoreBuiltinEditorModule.cpp b/Source/MetaCoreEditor/Private/MetaCoreBuiltinEditorModule.cpp index 0452388..2162b67 100644 --- a/Source/MetaCoreEditor/Private/MetaCoreBuiltinEditorModule.cpp +++ b/Source/MetaCoreEditor/Private/MetaCoreBuiltinEditorModule.cpp @@ -7969,16 +7969,32 @@ public: continue; } - bool hasComponentOnAllSelected = true; + std::size_t objectsWithComponent = 0; for (const MetaCoreId selectedId : editorContext.GetSelectedObjectIds()) { const MetaCoreGameObject selectedGameObject = editorContext.GetScene().FindGameObject(selectedId); - if (!selectedGameObject || !descriptor.HasComponent(selectedGameObject)) { - hasComponentOnAllSelected = false; - break; + if (selectedGameObject && descriptor.HasComponent(selectedGameObject)) { + ++objectsWithComponent; } } - if (!hasComponentOnAllSelected) { + if (objectsWithComponent == 0) { + continue; + } + + if (objectsWithComponent < selectedCount) { + ImGui::PushID(descriptor.TypeId.c_str()); + const std::string partialHeader = descriptor.DisplayName + " (" + std::to_string(objectsWithComponent) + "/" + std::to_string(selectedCount) + " selected)"; + if (ImGui::CollapsingHeader(partialHeader.c_str())) { + ImGui::TextDisabled("This component exists on only part of the current selection."); + if (ImGui::SmallButton("Add to Missing")) { + (void)MetaCoreMutateSelectedObjectWithComponentDescriptor(editorContext, descriptor, true); + } + ImGui::SameLine(); + if (ImGui::SmallButton("Remove from Present")) { + (void)MetaCoreMutateSelectedObjectWithComponentDescriptor(editorContext, descriptor, false); + } + } + ImGui::PopID(); continue; }