You are just declaring a pointer to UProgressBar
you are not creating the actual element. You need something like this:
bool UOLHpBarWidget::Initialize()
{
if(!Super::Initialize())
return false;
if(WidgetTree)
{
auto MyCanvas = WidgetTree->ConstructWidget<UCanvasPanel>(UCanvasPanel::StaticClass());
HpBar = WidgetTree->ConstructWidget<UProgressBar>(UProgressBar::StaticClass());
MyCanvas->AddChildToCanvas(HpBar);
WidgetTree->RootWidget = MyCanvas;
return true;
}
else
return false;
}
Or something along those lines… And no, I’ve not tested it. There is no force in the world that can make me build user interface in C++