There is very little documentation on more complex UMG architecture. Lets say I want to build something generic like shown here:
In UMG_Button, I would set up a hierarchy, consisting of a sizebox, housing a horizontal box which has the two objects “icon” and “title”. Now in Event Pre Construct I would set the “title”-text and “icon”-brush, using public variables.
In UMG_Scrollwindow, I would make a hierarchy, consisting of a sizebox, housing a vertical box which has a bunch of UMG_Button objects. The styling of those buttons I could directly change in the Detail Editor of each button.
However, now I want to draw two UMG_Scrollwindow objects to the viewport, so I create a third UMG, called UMG_Main which has two UMG_Scrollwindows. The issue is now: How would I style the buttons of each Scrollwindow indivudually directly from UMG_Main.
I see these options:
1.
Of course, I could just make two different versions of UMG_Scrollwindow but that seems wrong because I have to maintain two UMGs now.
2.
I could make one master UMG_Scrollwindow and have e.g. UMG_Scrollwindow_red and UMG_Scrollwindow_blue derive from the parent class. I would set up the buttons here, using the same hierarchy I formerly had in UMG_Scrollwindow add as many buttons as I want to UMG_Scrollwindow_red and blue and delete the Buttons in the parent class UMG_Scrollwindow. I then call the parent function in the child classes and redirect the vertical box component.
I would add logic to the parent class UMG_Scrollwindow, to be able to add icons and text for each button from within UMG_Main by creating components inside the public arrays, like so:
This works well, the downside. I need a child component for every individual Scrollwindow object. Also, I need to add a small delay in the pre construct event of UMG_Button, so it waits for UMG_Scrollwindow.
3.
Lets say, I want to set the number of UMG_Buttons inside UMG_Scrollwindow directly from UMG_Main and style them afterwards (which would be my prefered behavior). I would change the logic inside UMG_Scrollwindow like so:
Is there another, more elegant way to do this? I think this could get quite messy, once I allow more objects other than UMG_Button to be placed inside my UMG_Scrollwindow.