Access Material from Widget BP Hierarchy with C++

Hi all,

Is it possible to access the items within a Widget Blueprint’s Hierarchy from C++, specifically I’m try to access a Param from an image that is using a Material as it’s source?

110645-hierarchy.png

I’m adding the Widget to the viewport from code and have pointer to the Widget object:

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

	if (wIngameUI) // Check if the Asset is assigned in the blueprint.
	{
		// Create the widget and store it.
		MyIngameUI = CreateWidget<UUserWidget>(this, wIngameUI);

		// now you can use the widget directly since you have a reference for it.
		// Extra check to  make sure the pointer holds the widget.
		if (MyIngameUI)
		{
			//let add it to the view port
			MyIngameUI->AddToViewport();
		}

		//Show the Cursor.
		bShowMouseCursor = false;
	}
}

I’ve tried accessing this from another script and have tried getting it’s slots etc but everything seems to be coming back empty:

if (MyPlayerController)
	{
		UE_LOG(LogTemp, Warning, TEXT("MyPlayerController: %s"), *MyPlayerController->GetName());
		TArray<FName> slots;
		MyPlayerController->MyIngameUI->GetSlotNames(slots);

		for (int32 i = 0; i < slots.Num(); i++)
		{
			UE_LOG(LogTemp, Warning, TEXT("Slot Names: %s"), *slots[i].ToString());
		}
	}

Any help on how I can get to that magical Param within the material, within the UMG would be very gratefully received indeed.

Kindest regards

I seem to have the answer to this now.

I made a new c++ class that inherited from UUserWidget and reparented my Widget Blueprint to this. I then made a BlueprintImplementableEvent UFUNCTION in this new class, overriding it within the Blueprint; all it does is return the Image.

I haven’t looked into the Material Param yet, but I should be able to get the dynamic material from this returned image.