I’m working on the frontend of a game using UMG and predominantly blueprints. There’s a number of occasions where I’ve needed to iterate over all of the children in a derived Panel Widget to perform some operation in blueprint (eg. deselect all items in a Horizontal Box of radio box items because a new one is selected).
However, every time I do this, I can’t find any other way other than to effectively build up a index-based for loop in the blueprint using UPanelWidget::GetChildrenCount() and GetChildAt(…), something that comes out quite verbose and garish if trying to implement using blueprints:
What I was thinking about was implementing a simple, one-stop GetChildren() function on UPanelWidget to expose a non-index based method that can be hooked up straight to a ForEach in blueprints, in a consistent location with the rest of it’s UPanelWidget’s child management logic, providing simpler child traversal functionality to all UMG panels (scrollboxes, h-boxes, etc.):
However, before thinking about “giving back” to the Engine, I wanted to check with the Developers/community that I’ve not missed anything obvious.
There’s not some alternative way of doing this simply, which is already implemented, is there?
NB. I did find several forum posts in the past asking similar questions (eg here); the only solid recommendation I could find was to call WidgetTree() on the object, which returns an instance of the UWidgetTree transient utility class used for child traversal. However, this is specific to UUserWidget; it’s not implemented in UPanelWidget or any of its derived classes. Additionally I know there is the GetAllWidgetsOfClass library function, however this of course operates at the viewport level.