Use a list of duplicate buttons inside a widget

Hi,

for a specific project, I’m creating a list of 15 presets (similar to save game), wrapped inside a widget. Each line contains a slot name, a load, delete and assign button. The reason why each line has the same set of buttons is to make it as dummy-proof as possible (as it is used by users who are not computer savvy).

The way I’ve constructed this list is by creating a vertical box inside my main widget. The horizontal boxed is filled up by creating another widget (create widget of class) that consists of 1 line, including the text field (slot name) and the set of buttons. This is done 15 times so the vertical box gets populated. So, there are 15 instances of the same widget (each line) running in the background.

Everything is working fine though but my question is whether you think it is a good practice (in terms of performance/stability) to do so or if there are better ways to create this list?

Thanks for your suggestions!

if there are better ways to create
this list

If the performance is acceptable, it’s fine as is. If you ever need a performance boost, you can refactor using a List View. Example:

https://forums.unrealengine.com/development-discussion/blueprint-visual-scripting/1806576-creating-a-combat-log-in-blueprint?p=1806728#post1806728

These containers maintain the life of their widgets, removing and adding them on the fly - so only the recently needed elements contribute to the memory footprint.

It only makes sense to implement these if we’re talking about hundreds / thousands of elements and / or, imho, if the widgets themselves are complex enough to warrant the extra upfront work List View requires to set up.

Hi Everynone,

there are 15 presets that can be assigned/loaded when the preset (main) menu button is clicked. At that time, the 15 lines (widgets) are created. Each preset is a specific state in which the application should be in (eventually showing/hiding certain objects in the level). We do not know which preset the user wants to load/save so they should all be visible on screen at the same time. However, as soon as the preset is loaded or the widget screen is closed, the main widget is removed (node: remove from parent). However, the presets for some reason are not removed from memory (get all actors of class > remove from parent doesn’t work). I’m not sure if that’s a problem as they do not do anything in the background.

So, while there’s a binding to the
text field (slot name) in the widget
reference, it is supposed to update
only when it is called by the main
widget. Not sure if it is still firing
every frame though as it is indeed not
necessary.

Using Custom Events to update widgets is the right way to do it from my experience. If you have a bound function here on the other hand:

322580-screenshot-2020-11-20-121828.jpg

…it will execute every Tick. If the widgets cast in order to fetch data every frame, this can kill framerate rather quickly. If this field is bound to a simple text variable, it’s generally fine as is.

How many of these do you need displayed at the same time? As in, are they all visible at the same time all the time?

if there are better ways to create
this list

Another good idea is to avoid function binding in the widgets field. These fire every frame and one hardly every needs to update text every frame.

Whenever the slot name is updated by clicking the save button of the corresponding line, the slot name (separate screen generated by the main widget) is passed on to the widget reference from that particular line by calling an event from the main widget (which has the preset list) to that widget reference (line) and update its text. So, while there’s a binding to the text field (slot name) in the widget reference, it is supposed to update only when it is called by the main widget. Not sure if it is still firing every frame though as it is indeed not necessary.

OK, I’ll need to rewrite it. You are right! I still have a bound function in-place. I’ll switch to a custom event. Thanks for the tip.