How to make Slate Style work in game build?

In my code I create a simple menu widget of type derived from SCompoundWidget which contains two SButton widgets:

ChildSlot
									.VAlign(VAlign_Bottom)
									.HAlign(HAlign_Right)
									[
										SNew(SHorizontalBox)
											+ SHorizontalBox::Slot()
											.Padding(5.f)
											[
												SNew(SButton)
												.OnClicked(this,&SGUI_Widget::OptionsButtonClickHandler)
												.ButtonStyle(&FMyTestStyle::Get().GetWidgetStyle<FButtonStyle>("OptionsMenuButtonStyle"))
											]
											+ SHorizontalBox::Slot()
											.Padding(5.f)
											[
												SNew(SButton)
												.OnClicked(this, &SGUI_Widget::ExitButtonClickHandler)
												.ButtonStyle(&FMyTestStyle::Get().GetWidgetStyle<FButtonStyle>("ExitMenuButtonStyle"))
											]
									];

I also created two blueprints of ButtonWidgetStyle (named as mentioned in code) and assigned textures for different button states. It works as intended in editor, but when I package the project and execute that build those two buttons become two blank white squares without any textures. Packaged build directory contains all necessary assets (textures, styles).
There are some suspicious lines in log though, I think something is wrong with that:

Line 463: LogPlayLevel:Display: UE4Editor-Cmd: [2014.07.25-07.14.56:851][  0]LogPackageDependencyInfo:Display:  Package Info not found for ../../../TestGame/Content/Textures/Widgets/Buttons/ExitMenuButton!
Line 464: LogPlayLevel:Display: UE4Editor-Cmd: [2014.07.25-07.14.56:852][  0]LogPackageDependencyInfo:Display:  Package Info not found for ../../../TestGame/Content/Textures/Widgets/Buttons/ExitMenuButton_Hovered!
Line 465: LogPlayLevel:Display: UE4Editor-Cmd: [2014.07.25-07.14.56:852][  0]LogPackageDependencyInfo:Display:  Package Info not found for ../../../TestGame/Content/Textures/Widgets/Buttons/ExitMenuButton_Inactive!
Line 466: LogPlayLevel:Display: UE4Editor-Cmd: [2014.07.25-07.14.56:852][  0]LogPackageDependencyInfo:Display:  Package Info not found for ../../../TestGame/Content/Textures/Widgets/Buttons/ExitMenuButton_Pressed!
Line 467: LogPlayLevel:Display: UE4Editor-Cmd: [2014.07.25-07.14.56:852][  0]LogPackageDependencyInfo:Display:  Package Info not found for ../../../TestGame/Content/Textures/Widgets/Buttons/OptionsMenuButton!
Line 468: LogPlayLevel:Display: UE4Editor-Cmd: [2014.07.25-07.14.56:852][  0]LogPackageDependencyInfo:Display:  Package Info not found for ../../../TestGame/Content/Textures/Widgets/Buttons/OptionsMenuButton_Hovered!
Line 469: LogPlayLevel:Display: UE4Editor-Cmd: [2014.07.25-07.14.56:853][  0]LogPackageDependencyInfo:Display:  Package Info not found for ../../../TestGame/Content/Textures/Widgets/Buttons/OptionsMenuButton_Inactive!
Line 470: LogPlayLevel:Display: UE4Editor-Cmd: [2014.07.25-07.14.56:853][  0]LogPackageDependencyInfo:Display:  Package Info not found for ../../../TestGame/Content/Textures/Widgets/Buttons/OptionsMenuButton_Pressed!
Line 471: LogPlayLevel:Display: UE4Editor-Cmd: [2014.07.25-07.14.56:853][  0]LogPackageDependencyInfo:Display:  Package Info not found for ../../../TestGame/Content/UI/Style/ExitMenuButtonStyle!
Line 472: LogPlayLevel:Display: UE4Editor-Cmd: [2014.07.25-07.14.56:854][  0]LogPackageDependencyInfo:Display:  Package Info not found for ../../../TestGame/Content/UI/Style/OptionsMenuButtonStyle!

and while playing packaged or launched game I get:

LogPlayLevel:Display: TestGame: [2014.07.25-08.28.36:573][  6]LogSlateStyle:Error: USlateWidgetStyleAsset::GetStyle : No custom style set for '/Game/UI/Style/OptionsMenuButtonStyle.OptionsMenuButtonStyle'.LogSlateStyle:Error: USlateWidgetStyleAsset::GetStyle : No custom style set for '/Game/UI/Style/ExitMenuButtonStyle.ExitMenuButtonStyle'.

What am I doing wrong and what should I do to make it work?

1 Like

Ok, I found the problem source but didn’t find solution, just a workaround. It just doesn’t work if you make Slate Widget Style based on ButtonWidgetStyle.
It does work if you make your custom struct based on FSlateWidgetStyle with FButtonStyle member.

I didn’t check if other built-in Slate Widget Styles work or not. But I can’t make my buttons work with built-in ButtonWidgetStyle class.

So the safest way is to make your own FSlateWidgetStyle structs with members of types you need.
I mark this as resolved but I would be glad if someone will post a solution.

Also been wrestling with this bug for a few hours, thank you for the workaround!