I’m trying to make an inventory system for a “Mining Machine” where the item in the inventory constantly increases. The item will increase to a count of five, and then start filing in the next inventory slot. If i keep the ui open, it will never update, but if i close and reopen it will catch up. Everything looks to be working, except the widget wont update until i remove the widget and re-add it.
The Text widget is connected to the variable via binding
Any ideas would be appreciated. I’ve looked into Dispatchers and casting but all have the same result.
The data is accurately coming in, so not sure how the binding is not updating live
I assume you get the inventory structs on Widget Construct. Structure is copy be value, i.e. the moment the values are when you access it. You will need to do a broadcast every time struct value changes.
//On the class you store your inventory structures
1.Create an event dispatcher.
2.After each time the values are modified, call the event.
//On the widget class
1.Widget class on construct, bind the event to an event/function.
2.Do your function to fill your backpack widget like you shown on picture 2
No luck unfortunately . I have the inventory bp component calling the dispatch, then binding in the UI to an event that updates the text but still wont show changes till i close and reopen
After you have modified the struct in your inventory, the struct in your widget would be outdated. You need to get set it again to the struct in the widget.
Structs are not linked. They are local copies of the same struct. You will need to update your local struct every time the original changes.
Note:
You are binding the event on every single slot widget. I’d say the quickest way is to bind it on your Backpack widget. Every time inventory updates, clear out the slot widgets and recreate them using the new info again. Like re-open Backpack. This works fine for small amount of slots.