I want to update Widgets in response to GamePlayTags broacasted by the Gameplay Message Router. The broadcast and the listen for works just fine. The broacast is also able to get pointers to properties of the Widget.
I want to show/collapse a Progress Bar if a certain Tag is broadcasted. If i change the visibility in the callback, the original property is never updated. I suspect it does so because the callback does not run on game thread. Also if I try to set any other property there, the change is never reflected.
How do I change widgets in response to Listen for Messages callback?
The Progress Bar can be seen in view if i just spawn it with visiblity visible, so it can not be just behind some other widget or rendered outside the camera view.
I also tried to use AsyncTask to get the changes back to game thread, but it does not work either.
// Function to change the visibility of a progress bar
void UGCListenableWidget::SetProgressBarVisibility(UProgressBar* ProgressBar, ESlateVisibility NewVisibility)
{
if (!ProgressBar)
{
return; // Safety check to avoid null pointer access
}
// Ensure the operation runs on the game thread
AsyncTask(ENamedThreads::GameThread, [ProgressBar, NewVisibility]()
{
UE_LOG(LogTemp, Display, TEXT("ProgressBar Visibility Changed"));
if (ProgressBar && ProgressBar->IsValidLowLevelFast())
{
ProgressBar->SetVisibility(NewVisibility);
// Debug log to confirm execution
UE_LOG(LogTemp, Log, TEXT("Visibility set to: %d"), static_cast<int32>(NewVisibility));
}
});
}
Both log lines are logged in AsyncTask.
Setup
I copied plugin “GameplayMessageRouter” from Lyra and I enabled it in Unreal Editor.
The plugin is not mentioned in Build.cs or .urpoject. Could this be a problem?