Been slogging through docs and attempting several things to try to get an event hooked up in Python/PySide2 so I can be notified when the viewport selection changes (so I could pull out data for a tool)
What I’ve found is that in my PySide2 QMainWindow I did the following:
class MyMainWindow(QtWidgets.QMainWindow):
def __init__(self,parent=None):
super().__init__(parent)
self.ue_lvlsubsystem = unreal.get_editor_subsystem(unreal.LevelEditorSubsystem)
self.selection_set = self.ue_lvlsubsystem.get_selection_set()
self.selection_set.on_selection_change.add_callable(self.update_viewport_selection)
def update_viewport_selection(self, selection_set):
selected_elements = selection_set.get_selected_objects()
# do stuff with your selected objects
Just wanted to share this so it might help other people in the future