Hello every one. I want to know how to make USlateWidgetStyle work and add those styles to my widget.
I have created a style inherited from the USlateWidgetStyleContainerBase(present in the defualt class creation) and I have added code to it something similar to what is used in the shooter game. I have created the UI style assets in content browser derived from by slatestyle class and given them default properties.
I have a custom slate widget present at another place. But I am confused on how to link the style to the widget. Any tutorials present on the wiki regarding the style creation are a bit outdated,
Style.h
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "SlateWidgetStyleContainerBase.h"
#include "InventoryWidgetStyle.generated.h"
/**
*
*/
USTRUCT()
struct SURVIVALGAME_API FInventoryStyle : public FSlateWidgetStyle
{
GENERATED_USTRUCT_BODY()
FInventoryStyle();
virtual ~FInventoryStyle();
// FSlateWidgetStyle
virtual void GetResources(TArray<const FSlateBrush*>& OutBrushes) const override;
static const FName TypeName;
virtual const FName GetTypeName() const override { return TypeName; };
static const FInventoryStyle& GetDefault();
/** Design of the board outline*/
UPROPERTY(EditAnywhere, Category = Inventory)
FSlateBrush InventoryBorder;
FInventoryStyle& SetInventoryBorder(const FSlateBrush& InInventoryBorder) { InventoryBorder = InInventoryBorder; return *this; }
/** Design used by an empty slot icon*/
UPROPERTY(EditAnywhere, Category = Inventory)
FSlateBrush EmptySlotImg;
FInventoryStyle& SetEmptySlotImg(const FSlateBrush& InEmptySlotImg) { EmptySlotImg = InEmptySlotImg; return *this; }
};
/**
*/
UCLASS(hidecategories=Object, MinimalAPI)
class UInventoryWidgetStyle : public USlateWidgetStyleContainerBase
{
GENERATED_BODY()
public:
/** The actual data describing the widget appearance. */
UPROPERTY(Category=Appearance, EditAnywhere, meta=(ShowOnlyInnerProperties))
FInventoryStyle WidgetStyle;
virtual const struct FSlateWidgetStyle* const GetStyle() const override
{
return static_cast< const struct FSlateWidgetStyle* >( &WidgetStyle );
}
};
Style.cpp
#include “SurvivalGame.h”
#include “InventoryWidgetStyle.h”
FInventoryStyle::FInventoryStyle()
{
}
FInventoryStyle::~FInventoryStyle()
{
}
const FName FInventoryStyle::TypeName(TEXT("FInventoryStyle"));
const FInventoryStyle& FInventoryStyle::GetDefault()
{
static FInventoryStyle Default;
return Default;
}
void FInventoryStyle::GetResources(TArray<const FSlateBrush*>& OutBrushes) const
{
// Add any brush resources here so that Slate can correctly atlas and reference them
OutBrushes.Add(&InventoryBorder);
OutBrushes.Add(&EmptySlotImg);
}
How do I link it to my widget class?