I have a dialog screenwith character icon and I need to be able to set up this image in code. But I don’t know how to access this Image component (I put material instances in it).
.h
UPROPERTY(EditAnywhere) TSubclassOf<UUserWidget> widgetDialogBottom;
UUserWidget* widgetDialogBottomInstance;
.cpp
widgetDialogBottomInstance = CreateWidget<UUserWidget>(GetWorld(), widgetDialogBottom);
widgetDialogBottomInstance->Image("mi_dialog_2"); // Need something like this
widgetDialogBottomInstance->AddToViewport();
I made a class DialogBottomWidget:
.h
UCLASS()
class HOME_API UDialogBottomWidget : public UUserWidget
{
GENERATED_BODY()
public:
void SetImage(UTexture2D* InTexture);
private:
UPROPERTY(meta = (BindWidget)) UImage* CharacterPreview;
};
.cpp
#include "DialogBottomWidget.h"
void UDialogBottomWidget::SetImage(UTexture2D* InTexture)
{
CharacterPreview->SetBrushFromTexture(InTexture);
}
… and then I made a blueprint based on that class. What should I do now?