I’m trying to make a game on unreal engine 5. According to the lessons (and logic) in the blueprint widget, you can create a public image variable and change it whenever you want (in extreme cases, you can bind properties, although it calls every frame). In version 5.1, the ability to create public variables in the bluepirnt widget disappeared, epic games developers gave us ViewModel mechanism, which is only available only through C ++ by now. Question here: how do I change the image in the image widget (or any other widget with a picture) in the unreal engine 5.2.1?
i used this C++ ViewModel class:
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
include “CoreMinimal.h”
include “MVVMViewModelBase.h”
include “VMM_icons.generated.h”
/**
*
/
UCLASS(BlueprintType)
class GALAXYOFMYSTICHEROES_API UVMM_icons : public UMVVMViewModelBase
{
GENERATED_BODY()
public:
UPROPERTY(BlueprintReadWrite, FieldNotify, Setter, Getter)
UTexture2D MyIcon;
private:
void SetMyIcon(UTexture2D* newTexture)
{
UE_MVVM_SET_PROPERTY_VALUE(MyIcon, newTexture);
UE_MVVM_BROADCAST_FIELD_VALUE_CHANGED(GetIcon);
}
UTexture2D* GetMyIcon() const
{
return MyIcon;
}
public:
UFUNCTION(BlueprintPure, FieldNotify)
UTexture2D* GetIcon() const
{
return MyIcon;
}
};
this is the error i am getting
Binding ‘AbilityIMage.Brush.ResourceObject ← VMM_test.MyIcon’: Could not create binding. Couldn’t create the destination field path ‘AbilityIMage.Brush.ResourceObject’. Property Brush has getter accessor. Accessor not supported on FStructProperty since it would create a temporary structure and we would not able to return a valid container from that structure.
how to fix this?