I want to call function, which changes the text inside the widget.
There is a virtual function NativeConstruct, which calls automatically. And it changes text of widget, but I need to call function F1 and send a text to it, which I want to display. But when I call it, the variable Name is nullptr. And by some reason, it is not nullptr, when program call NativeConstruct.
- Nameis my text variable, which I want to change
- dialogBottomis the name of widget with this variable
Edited
UAccessWidgetFromCpp* AccessWidgetFromCpp 
= CreateWidget<UAccessWidgetFromCpp>(
      GetWorld()->GetFirstPlayerController(), UAccessWidgetFromCpp::StaticClass()
   );
if (AccessWidgetFromCpp)
{
   AccessWidgetFromCpp->F1("222");
   widgetDialogBottomInstance->AddToViewport();
}
UCLASS()
class HOME_API UAccessWidgetFromCpp : public UUserWidget
{
   GENERATED_BODY()
public:
   UPROPERTY(BlueprintReadOnly, meta = (BindWidget))
   class UTextBlock* Name = nullptr;
   UFUNCTION()
   void F1(FString text);
};
void UAccessWidgetFromCpp::F1(FString text)
{
   if (auto widget = dynamic_cast<UTextBlock*>(GetWidgetFromName(TEXT("Name"))))
   {
      Name = widget;
      Name->SetText(FText::FromString(text));
   }
}


 
     
    