UImage->SetBrushSize doesn't work anymore in UE5 (was ok in UE4)

Hi,
I had a game in UE4 which was dynamically creating tiles for a gameboard using UImage and SetBrushSize to set the size of the tile.

But it’s not working anymore in UE5. I see the function is deprecated:

	UE_DEPRECATED(5.0, "Deprecated. Use SetDesiredSizeOverride instead.")
	void SetBrushSize(FVector2D DesiredSize);

but using SetDesiredSizeOverride is not working as well.

Hey,
I found out the solution.

Use this instead:

    FSlateBrush mybrush = imageBG->Brush;
    mybrush.SetImageSize(FVector2D(size, size));
    imageBG->SetBrush(mybrush);

it sets the size of the image through the brush, and this actually worked for me.

Since 5.2 also direct access to the Brush is deprecated. Quickly fixed by creating the new brush using the getter instead.

    FSlateBrush mybrush = imageBG->GetBrush();
    mybrush.SetImageSize(FVector2D(size, size));
    imageBG->SetBrush(mybrush);

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