use pure c++ create a c++ UUserWidget ,cant show in Viewport!
1.when I use c++ create,it didn’t show, but anything is work,like call this class function.
I have been check any Visibililty ,bEnable or any state of this widget,all is fine!
UCanvasWidget* Instance = CreateWidget<UCanvasWidget>(World, UCanvasWidget::StaticClass(), FName("1.UUserWidget"));
Instance->RootPanel = Instance->WidgetTree->ConstructWidget<UCanvasPanel>(UCanvasPanel::StaticClass(),FName("2.CanvasPanel"));
UImage* Image = Instance->WidgetTree->ConstructWidget<UImage>(UImage::StaticClass(),FName("3.UImage"));
Instance->RootPanel->AddChild(Image);
Instance->WidgetTree->RootWidget = Instance->RootPanel;
Instance->AddToViewport();
2.I use the blueprint to inherit my class :UCanvasWidget:UUserWidget
,it can show uimage graphic or added UWidget element, normally.
final:i guess its a problem between bp and c++,bp has solve some other invisible step to make it!
any idea,my genius friend?
Mu Chung is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.