How do I update things in my slate

I drew a Int concerted to FText in slate. I wish to update it over time, how do I do it?

void SMyUIWidget::Construct(const FArguments& InArgs)
{
	OwnerHUD = InArgs._OwnerHUD;
	////////////////////////////////////////////////////////////////////////////////////////////////////
	/////If the code below doesn't look like C++ to you it's because it (sort-of) isn't,
	/////Slate makes extensive use of the C++ Prerocessor(macros) and operator overloading,
	/////Epic is trying to make our lives easier, look-up the macro/operator definitions to see why.
	ChildSlot
		.VAlign(VAlign_Top)
		.HAlign(HAlign_Center)
		[
			SNew(SOverlay)
			+ SOverlay::Slot()
			.VAlign(VAlign_Fill)
			.HAlign(HAlign_Fill)
			[
				SNew(SHorizontalBox).Visibility(EVisibility::Visible)
				//Add slots to HorizontalBox, these will hold images
				+ SHorizontalBox::Slot().HAlign(HAlign_Left).VAlign(VAlign_Bottom)
				[   //
					SNew(STextBlock)
					.ShadowColorAndOpacity(FLinearColor::Black)
					.ColorAndOpacity(FLinearColor::White)
					.ShadowOffset(FIntPoint(-1, 1))
					.Font(FSlateFontInfo("Veranda", 16)) //don't think this actually changes the font
					.Text(FText::FromString("Hello, Slate!"))
				]
				+ SHorizontalBox::Slot().HAlign(HAlign_Left).VAlign(VAlign_Bottom)
					[   //
						SNew(STextBlock)
						.ShadowColorAndOpacity(FLinearColor::Black)
						.ColorAndOpacity(FLinearColor::White)
						.ShadowOffset(FIntPoint(-1, 1))
						.Font(FSlateFontInfo("Veranda", 30)) //don't think this actually changes the font
						.Text(FText::FromString(FString::FromInt(OwnerHUD->StoredScore)))
					]
			]
		];
}

.Text can take a delegate as well as a static variable.

.Text(FText::FromString(FString::FromInt(OwnerHUD->StoredScore)))

becomes

.Text(this, &MyClass::GetStringFunction)


FText MyClass::GetStringFunction()
{
   return FText::FromString(FString::FromInt(OwnerHUD->StoredScore));
}

Here’s an optimization to your string formatting

FText::Format(NSLOCTEXT("LocNamespace", "LocScoreAttrName", "Score: {0}"), FText::AsNumber(OwnerHUD->StoredScore));

But is this going to update over time? When the int changes in the HUD class?

And slate keeps on updating itself once it is constructed?

Like the DrawHud is called each frame something similar to that?

I forgot to mention, I drew slate from BeginPlay in HUD class…

I started learning slate yesterday so I am not sure about a lot of things.

void AMyProjectHUD::BeginPlay()
{
	Super::BeginPlay();

	////////////////////////////////////////////////////////////////////////////////////////////////////
	/////So far only TSharedPtr<SMyUIWidget> has been created, now create the actual object.
	/////Create a SMyUIWidget on heap, our MyUIWidget shared pointer provides handle to object
	/////Widget will not self-destruct unless the HUD's SharedPtr (and all other SharedPtrs) destruct first.
	SAssignNew(MyUIWidget, SMyUIWidget).OwnerHUD(this);

	////////////////////////////////////////////////////////////////////////////////////////////////////
	/////Pass our viewport a weak ptr to our widget
	if (GEngine->IsValidLowLevel())
	{
		GEngine->GameViewport->
			/*Viewport's weak ptr will not give Viewport ownership of Widget*/
			AddViewportWidgetContent(SNew(SWeakWidget).PossiblyNullContent(MyUIWidget.ToSharedRef()));
	}

	if (MyUIWidget.IsValid())
	{
		////////////////////////////////////////////////////////////////////////////////////////////////////
		/////Set widget's properties as visible (sets child widget's properties recursively)
		MyUIWidget->SetVisibility(EVisibility::Visible);
	}
}

The idea of a delegate in place of static text is that Slate will ask you via this function every time it wants to know the answer to the question “what text goes here”. So yes, everything time StoredScore changes it will be reflected when Slate asks about it.

Slate does its own ticking and by design will update itself according to the description of the widgets you wrote above.

In your original case, each tick Slate will ask what you want the text to be and you said “make my text say X always” and I have made the changes to that above to say “make my text say whatever GetStringFunction tells you”.

I’m not the best about the connecting up to Slate itself. I typically add children to our game’s existing Slate structure.

Your MyUIWidget has been constructed, passed to the viewport and set to visible. That looks correct to me.