Skip to main content

Initialize a Stat Widget

HF Stats provides a unique way to initialize Stat Widgets.
All widgets that implement the IStatWidgetInterface can be initialized through InitializeWidgets() or InitializeWidgets_FromStat().

These functions will try to initialize the target Widget and recursively initialize every widget inside of it using the StatsComponent provided.
This means it can be used on any container (Canvas panel, horizontal box, even buttons, etc.) or any custom blueprint widget.
It can also be used directly on the Stat Widget.

Additionnally, InitializeWidgets_FromStat() will override the Target Stat with the specified one on all widgets found.

info

Since this function looks for all widgets or containers within a widget or container, try to use it mindfully. Do not use it directly on your main widget if it has tons of nested widgets and only 10% of those are Stat Widgets.
In those cases, try to use these functions directly on the widgets / containers that actually contain Stat Widgets.

note

Right now, you can't implement the IStatWidgetInterface in your own Blueprint Widgets, so these two functions will only work for widgets directly provided by the plugin.

Example

In this example, calling InitializeWidgets() directly on my custom blueprint widget will initialize the ReactiveProgressBar_Stat, the 3 TextBlock_StatName and the 3 TextBlock_StatValue.

I could also call it on my Canvas Panel, or individually on each Stat Widget.