-
- David Jefferies
- Posts: 27
- Joined:
Binding to Unreal textures in C++
Is there a C++ code snippet to show how to bind an Unreal texture uasset to a Xaml Image?
QuestLog has this Xaml:
In the project SelectedQuest.Image is defined and assigned in a Blueprint.
I'm interested in how to define and assign it in C++
QuestLog has this Xaml:
Code: Select all
<Image Grid.Row="1" Source="{Binding SelectedQuest.Image}" Margin="1,0"/>I'm interested in how to define and assign it in C++
Re: Binding to Unreal textures in C++
Hi David,
This could be the equivalent native code for the QuestLog sample:
All you have to do is create an UPROPERTY with type UTexture2D that is either BlueprintReadWrite or BlueprintReadOnly.
Hope this helps.
This could be the equivalent native code for the QuestLog sample:
Code: Select all
#include "CoreMinimal.h"
#include "UObject/NoExportTypes.h"
#include "Engine/Texture2D.h"
#include "Quest.generated.h"
UENUM(BlueprintType)
enum class EQuestDifficulty : uint8
{
Easy,
Normal,
Hard
};
UCLASS(BlueprintType)
class SAMPLESMODULE_API UQuest : public UObject
{
GENERATED_BODY()
public:
UPROPERTY(BlueprintReadWrite)
FString Title;
UPROPERTY(BlueprintReadWrite)
UTexture2D* Image;
UPROPERTY(BlueprintReadWrite)
EQuestDifficulty Difficulty;
UPROPERTY(BlueprintReadWrite)
FString Description;
UPROPERTY(BlueprintReadWrite)
bool Completed;
UQuest() {}
UFUNCTION(BlueprintCallable)
void Initialize(const FString& InTitle, UTexture2D* InImage, EQuestDifficulty InDifficulty, const FString& InDescription, bool InCompleted)
{
Title = InTitle;
Image = InImage;
Difficulty = InDifficulty;
Description = InDescription;
Completed = InCompleted;
}
};
Hope this helps.
Who is online
Users browsing this forum: Bing [Bot] and 5 guests