This gives us easier access to the modifier keys, simplifying our Python requirements and ease of us:
EditorActorSubsystem = unreal.get_editor_subsystem(unreal.EditorActorSubsystem)
selection = set()
def update_selection():
"""Set or update the current selection"""
global selection
new_selection = EditorActorSubsystem.get_selected_level_actors() or []
is_shift_down = unreal.InputLibrary.modifier_keys_state_is_shift_down(
unreal.InputLibrary.get_modifier_keys_state()
)
# If shift is down, add to the selection
# otherwise, replace the selection
if is_shift_down:
selection |= set(new_selection)
else:
selection = set(new_selection)
print("Current Selection:")
for actor in selection:
print(f"\t{actor.get_actor_label()}")
Not really groundbreaking, but there's a lot of neat little things in the Python Docs to discover