How to update properties in callback of Listen for Messages (GameplayMessageRouter Plugin)

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?

I made a small setup with ThirdPersonTemplate just to validate how this would work. It worked immedatly. Later I found out my issue is not the subsystem, but rather that I endlessly create new widgets, without ever destroying them. If this symptom would not have occurred, I think this would have lead to a memory leak later.

I will redo the widget logic now, to reuse widgets instead of creating and deleting them. I also feel this is more like epic designed wigdets to be used.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.