I’m trying to create a bar that can be dinamically filled/emptied by using two +/- buttons. It works by using several instances of two simple widgets that contain the images for empty or full. The bar in question:
The problem is that everytime I change the value of the bar I have to go through all children to find the first empty child (or full, depending if I’m adding/subtracting). Then when I have the index of the child I have to switch from empty to full, or vice versa, I have to remove all children from that point to the end (GetChildrenCount), and then add the child with the new value, and then finally recreate the rest of the bar with new empty widgets.
Now, this works fine, but by using it ingame a few times, a lot of empty/full widgets are created and abandoned very quickly. This is because UMG widgets can’t actually be destroyed at runtime but just sit there, waiting to be collected by the gc. I find this is not a healthy solution, and would love to be able to just “switch” a widget’s class at runtime or more realistically to be able to dynamically add a new child at a given index with the existing children’s indexes updating automatically.
PS: I find it strange that basically no one, a part from one single guy in AnswerHub (that received no answers from January), has pointed this out already, so I figure there probably is a more intelligent way of doing simple bars like this I’m trying to do, and that my stupid brain just hasn’t thought of it… so if there’s a better way could any one please illuminate me?
Thanks in advance, and sorry for all these many words but I’m very tired, and I’m not being able to synthesize concepts correctly