UMG as a framework has grown on me quite a bit over the years. It took a little getting used to, but several things about it have opened ideas up in my brain that show the true power of UI in UE4. Named Slots are one of the simpler features that I think give UMG a lot of its power. A named slot is basically a publicly exposed slot on a widget, so that when you add it to another widget, the slot shows up in the widget tree and you can then add things inside of it.

I make heavy use of this in Orb Rivals, particularly in the Play menu above. The use cases are pretty extensive, but boil down to anywhere you want a consistent but complicated widget shell, and want to customize the content inside one or more parts of it without the hassle of hooking up a bunch of bindings or variable juggling in the preconstructor.

In my case, I have these MenuTile widgets with a slot on them named TileContent. I have some expectations about what will be placed in that slot (specifically a widget subclassing a common TileContent widget I have), mainly because of the alternative keyboard/gamepad selection framework I've built up, but you can access the slot's children in your blueprint graph just like any other container widget. This allows the parent widget with the named slot to key off of events coming from its children in a consistent way, without it needing to know specifically what those children are.

The main benefit over just using a VerticalBox or any other panel really comes down to reuse. In my MenuTile widget class I handle mouse and selection events, so all of the logic and visual effects related to a menu tile are all encapsulated in this one class that I can reuse everywhere, but I can still fully customize the content within an individual tile.

by David "Stalefish" Talley on September 7th, 2019