Hello, I have made a custom slate widget. It has a TAttribute which I want to set each time I create the slate widget. Something like this
class SURVIVALGAME_API SItemWidget : public SCompoundWidget
{
public:
SLATE_BEGIN_ARGS(SItemWidget)
:_GameHUD()
{}
SLATE_ARGUMENT(TWeakObjectPtr<class ATestHUD>, GameHUD)
SLATE_ATTRIBUTE(int32, Test)
SLATE_END_ARGS()
public:
/** Constructs this widget with InArgs */
void Construct(const FArguments& InArgs);
private:
TWeakObjectPtr<class ATestHUD> GameHUD;
TAttribute<int32> Test;
TWeakObjectPtr<class ATestHUD> ParentInventoryWidget;
};
I create this slate widget inside another slate widget something like this
TSharedPtr<SVerticalBox> Col;
SAssignNew(Col, SVerticalBox);
for (int32 i = 0; i < 4; i++)
{
Col->AddSlot()
.HAlign(HAlign_Fill)
.VAlign(VAlign_Fill)
[
SNew(SItemWidget)
.GameHUD(GameHUD)
.Test(i)
];
}
But when I access the slate values all values appear to be zeros
ChildSlot
[
SNew(SBox)
.Padding(5)
.HeightOverride(100)
.WidthOverride(100)
[
SNew(SBox)
.HAlign(HAlign_Center)
.VAlign(VAlign_Center)
[
SNew(STextBlock)
.Text(FText::FromString(FString::FromInt(Test.Get())))
]
]
];
But this doesn’t work and all values appear to be zeroes.