Can’t seem to get my custom background brush, or any brush for that matter, to draw. It draws a flat grey background instead of the image. I’m assuming I’m doing something wrong in the code. This is in a standalone slate program.
Loading the background image in the custom style.
#define IMAGE_BRUSH( RelativePath, ... ) FSlateImageBrush( Style->RootToContentDir( RelativePath, TEXT(".png") ), __VA_ARGS__ )
#define BOX_BRUSH( RelativePath, ... ) FSlateBoxBrush( Style->RootToContentDir( RelativePath, TEXT(".png") ), __VA_ARGS__ )
#define BORDER_BRUSH( RelativePath, ... ) FSlateBorderBrush( Style->RootToContentDir( RelativePath, TEXT(".png") ), __VA_ARGS__ )
#define TTF_FONT( RelativePath, ... ) FSlateFontInfo( Style->RootToContentDir( RelativePath, TEXT(".ttf") ), __VA_ARGS__ )
#define OTF_FONT( RelativePath, ... ) FSlateFontInfo( Style->RootToContentDir( RelativePath, TEXT(".otf") ), __VA_ARGS__ )
TSharedRef< FSlateStyleSet > FMyStyle::Create()
{
TSharedRef< FSlateStyleSet > Style = MakeShareable(new FSlateStyleSet(FMyStyle::GetStyleSetName()));
Style->SetContentRoot(FPaths::GameContentDir() / TEXT("Slate"));
Style->Set("MainWindow", FWindowStyle()
.SetBackgroundBrush(IMAGE_BRUSH("MyImage", FVector2D(912, 582), FLinearColor::White, ESlateBrushTileType::NoTile))
);
return Style;
}
#undef IMAGE_BRUSH
#undef BOX_BRUSH
#undef BORDER_BRUSH
#undef OTF_FONT
#undef TTF_FONT
And usage of the custom style.
TSharedRef<SWindow> TestWindow = SNew(SWindow)
.ClientSize(FVector2D(912, 582))
.AutoCenter(EAutoCenter::PrimaryWorkArea)
.Style(FMyStyle::Get(), "MainWindow");
FSlateApplication::Get().AddWindow(TestWindow);