Download

Setting default slate style in umg class crashes the editor

I am trying to set a default widget style for my custom UMG class. I have already created all the accompanying Slate classes, and have successfully setup my project to use custom styles. I have closely followed some of the available Slate classes and their corresponding UMG classes and through there, I came to the following solution;

The constructor for Mywidget.cpp


        UBK_UIWidget_ItemboxSimple::UBK_UIWidget_ItemboxSimple(const FObjectInitializer& ObjectInitializer)
        	: Super(ObjectInitializer)
        {
        	SBK_UIWidget_ItemboxSimple::FArguments DefaultItemBox;
        	WidgetStyle = *DefaultItemBox._ItemboxStyle;
        }

and the corresponding FArguments part of the slate class


        class SBK_UIWidget_ItemboxSimple : public SCompoundWidget
        {
        public:
        
        	SLATE_BEGIN_ARGS(SBK_UIWidget_ItemboxSimple)
        		: _Content()
        		, _BackgroundImage(GetIcon())
        		, _BackgroundColorAndOpacity(FLinearColor::White)
        		, _BackgroundPadding(FMargin(10.f, 10.f, 0.f, 0.f))
        		, _AmmoImage(GetIcon())
        		, _AmmoColorAndOpacity(FLinearColor::White)
        		, _AmmoPadding(FMargin(0.f, 0.f, 0.f, 0.f))
        		, _ItemboxStyle(&FBK_SlateStyles::Get().GetWidgetStyle< FItemboxSimpleStyle >("ItemboxSimple"))
        		, _NoOpacity(FLinearColor(0.f, 0.f, 0.f, 0.f))
        	{}
        		SLATE_DEFAULT_SLOT(FArguments, Content)
        
        		SLATE_ATTRIBUTE(const FSlateBrush*, BackgroundImage)
        
        		SLATE_ATTRIBUTE(FSlateColor, BackgroundColorAndOpacity)
        
        		SLATE_ATTRIBUTE(FMargin, BackgroundPadding)
        
        		SLATE_ATTRIBUTE(const FSlateBrush*, AmmoImage)
        
        		SLATE_ATTRIBUTE(FSlateColor, AmmoColorAndOpacity)
        
        		SLATE_ATTRIBUTE(FMargin, AmmoPadding)
        
        		SLATE_STYLE_ARGUMENT(FItemboxSimpleStyle, ItemboxStyle)
        
        		SLATE_ATTRIBUTE(FSlateColor, NoOpacity)
        
        	SLATE_END_ARGS()
        
        ...etcetera

Whenever I implement it like this, it just crashes the editor right away without fail. I have closely studied the SButton and Button classes, but while for the Button this implementation works, it doesn’t for mine. Anyone knows how I can set the default widget style, so I get to see the defaults for this style whenever I use this UMG class?