Hi there, I’m having an issue with a widget im creating to track the stats of my game (Wiki system).
I dynamically track consumables using two widgets (Wiki_Button
and 1412
- my Inventory). The system works fine when toggling the Wiki system using a button, but I want to move the widget initialization logic to Event Construct
to avoid recreating widgets multiple times. However, when I move the logic, the integer array values aren’t updating properly, and I’m stuck trying to understand why and I already spent almost a week on this so I’d appreciate any guidance or suggestions, please.
System Overview:
Wiki_Button
Widget: Displays information about a single consumable (image texture and integer value showing the consumption count).1412
Widget: Dynamically creates 40 instances ofWiki_Button
and arranges them in a grid using a custom function calledUpdateStats
.- Data Handling: The
GameStats
variable (a struct with 40 integers) is pulled from my character blueprint to track how many consumables have been used.
Issue:
The system works perfectly when using an event-based approach (i.e., clicking a button to toggle the visibility of the Wiki), and it updates the Wiki_Button
widgets correctly. However, this creates the 40 widgets every time, which is not efficient. I want to move the logic to Event Construct
so I can just update the stats and toggle visibility on and off… but when I do, the integer array values don’t update properly—they remain the same across all widgets.
I tried to destroy/unparent the widgets, but this wasn’t a good solution either. My goal is to create the widgets once and then simply hide/unhide them when toggling the Wiki system.
What I’ve Tried:
- Moving the widget creation and
UpdateStats
call toEvent Construct
and using a toggle for visibility. However, the array values (fromGameStats
) aren’t updating correctly inEvent Construct
as they do in the button-click event. - Debugging showed that the array increments properly when consumables are used, but the widgets don’t reflect these updates when the code is moved to
Event Construct
.
1412:
Wiki_Button:
P.S: The GameStats (coming from an interface from my character BP) works fine as when I debug with print string and tracks each integers are updated correctly. Thank you for your time