feat(editor): show partial components in multi-select inspector
This commit is contained in:
parent
c0e9dc1efe
commit
0a6ee85e08
@ -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;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user