updating HUD on tick is killing frame rate

Hi, I have a custom HUD in the editor, I have had to change how I do this in 4.13, and am having problems…

I have a widget, and every tick it updates. What I want to do is update the displayed value, but it seems to be creating a new SOverlay every tick, and killing my fps. Where am i going wrong here? How can I clear the baseWidget and rebuild it, every tick? OR, just update the value in the STextBlock?

Thanks!


FLevelEditorModule& LevelEditor = FModuleManager::GetModuleChecked<FLevelEditorModule>(TEXT("LevelEditor"));

	TSharedPtr<ILevelViewport> LViewport = LevelEditor.GetFirstActiveViewport();
	

	TSharedRef<SWidget> baseWidget = SNew(SOverlay)
		+ SOverlay::Slot()
		.VAlign(VAlign_Bottom)
		.HAlign(HAlign_Fill)
		
			//Colored Background
			SNew(SBorder)
			.Padding(FMargin(2))
		//  Image for BG
		.BorderImage(&brushClr)

		
		
			
			SNew(STextBlock)
			.Justification(ETextJustify::Right)
		.Text(RecHUDText)
		.Margin(15)
		.ColorAndOpacity(FLinearColor::Red)
		.Font(FSlateFontInfo("Veranda", 20))

		]
		]
	LViewport->RemoveOverlayWidget(baseWidget);
	LViewport->AddOverlayWidget(baseWidget);

I’m no slate expert, but on first glance, it looks like you’re trying remove a new baesWidget rather then a reference to the old one.
Additionally, you should be able to specify a callback for the STextBlock so it’ll update its own text.
Don’t ask me how… haven’t done it in ages.
UMG FTW :stuck_out_tongue:

I second the recommendation for UMG :slight_smile:
However, re-creating the widgets each frame is a sure way to lose performance.
Just update whatever it is you need updating.