Hey guys,
I’m trying to set an an image at runtime in a widget.
UImage* UManager::getImage()
{
// tried both
// FString Path = FString("/Game/Asset/Textures/texture.texture");
FString Path = FString("/Game/Asset/Textures/texture");
UTexture2D* Texture = Cast<UTexture2D>(StaticLoadObject(UTexture2D::StaticClass(), NULL, *Path));
UImage* Image = ConstructObject<UImage>(UImage::StaticClass());
Image->SetVisibility(ESlateVisibility::Visible);
Image->SetBrushFromTexture(Texture);
Image->SetOpacity(50.5f);
UE_LOG(LogTemp, Warning, TEXT("Log")); // will be logged in the console
return Image;
}
The Widget’s graph looks like this:
“Get Own Pokemon Sprite” = “getImage()”
Unfortunately it has absolutely no effect and it doesn’t change anything. If I change the image manually in the widget to the texture it will be displayed properly. The image is set to variable. I have no clue what else to do.
I appreciate every hint,
thanks!