I’ve been trying to get my SCompoundWidget child class to work for sometime now but can’t seem to find any documentation on the matter. The widget I’m trying to make is a widget that will have images to show all the materials available.
This is what the .h looks like:
#include "SlateBasics.h"
#include "SCompoundWidget.h"
#include "SlateMaterialBrush.h"
class MY_API SMaterialChangerWidget : public SCompoundWidget
{
public:
SLATE_BEGIN_ARGS(SMaterialChangerWidget)
{}
SLATE_END_ARGS()
/** Constructs this widget with InArgs */
void Construct(const FArguments& InArgs);
const TSharedRef<STableViewBase> OnGenerateTile();
private:
TSharedPtr<SVerticalBox> container;
TArray<TWeakObjectPtr<UMaterialInterface>> materialTileImages;
TSharedRef<ITableRow> OnGenerateTile(TWeakObjectPtr<AActor> item, const TSharedRef<STableViewBase>& ownerTable);
};
And the .cpp looks like this:
#include "SMaterialChangerWidget.h"
BEGIN_SLATE_FUNCTION_BUILD_OPTIMIZATION
void SMaterialChangerWidget::Construct(const FArguments& InArgs)
{
ChildSlot
.HAlign(HAlign_Left)
.VAlign(VAlign_Top)
[
// Populate the widget
SAssignNew(container, SVerticalBox)
];
container->AddSlot()
.AutoHeight()
.Padding(FMargin(0, 5))
[
SNew(STileView<TWeakObjectPtr<UMaterialInterface>>)
.ItemHeight(48)
.ItemHeight(24)
.ListItemsSource(&materialTileImages)
.OnGenerateTile(this, &SMaterialChangerWidget::OnGenerateTileForWidget)
];
}
TSharedRef<ITableRow> SMaterialChangerWidget::OnGenerateTileForWidget(TWeakObjectPtr<AActor> item, const TSharedRef<STableViewBase>& ownerTable)
{
UMaterialInterface* materialInterface = Cast<UMaterialInterface>(item.Get());
if (materialInterface)
{
const FSlateMaterialBrush* currentMaterial = new FSlateMaterialBrush(*materialInterface, FVector2D(20, 20));
return SNew(STableRow<TSharedPtr<SWidget>>, ownerTable)
[
SNew(SImage)
.Image(currentMaterial)
];
}
else
{
return SNew(STableRow<TSharedPtr<SWidget>>, ownerTable)
[
SNew(STextBlock)
.Text(TAttribute<FString>(TEXT("UNKNOWN Type")))
];
}
}
END_SLATE_FUNCTION_BUILD_OPTIMIZATION
And the error I receive is: “IntelliSense: no instance of overloaded function “STileView::FArguments::OnGenerateTile [with ItemType=TWeakObjectPtr]” matches the argument list
argument types are: (SMaterialChangerWidget , TSharedRef<ITableRow, ESPMode::NotThreadSafe> (SMaterialChangerWidget::)(TWeakObjectPtr<AActor, FWeakObjectPtr, FIndexToObject> item, const TSharedRef<STableViewBase, ESPMode::NotThreadSafe> &ownerTable))
object type is: STileView<TWeakObjectPtr<UMaterialInterface, FWeakObjectPtr, FIndexToObject>>::FArguments”
What is the correct way to call the “OnGenerateTile”?