You may want to construct a Blueprints editable property in UE4 that contains multiple members. The FColoredTexture
struct that we will create in this chapter will allow you to group together a texture and its color inside the same structure for inclusion and specification in any other UObject
derivative, Blueprintable
class:
The FColoredTexture
structure does have the visual within Blueprints appearance as shown in the figure above.
This is for good organization and convenience of your other UCLASS
UPROPERTIES()
. You may want to construct a C++ structure in your game using the keyword struct
.
A UObject
is the base class of all UE4 class objects, while an FStruct
is just any plain old C++ style struct. All objects that use the automatic memory management features within the engine must derive from this class.
We'll create a structure FColoredTexture
in C++ code to contain a texture and a modulating color:
ColoredTexture.h
in your project folder (not FColoredTexture
).ColoredTexture.h
contains the following code:#pragma once #include "Chapter2.h" #include "ColoredTexture.generated.h" USTRUCT() struct CHAPTER2_API FColoredTexture { GENERATED_USTRUCT_BODY() public: UPROPERTY( EditAnywhere, BlueprintReadWrite, Category = HUD ) UTexture* Texture; UPROPERTY( EditAnywhere, BlueprintReadWrite, Category = HUD ) FLinearColor Color; };
ColoredTexture.h
as a UPROPERTY()
in some Blueprintable UCLASS()
, using a UPROPERTY()
declaration like this:UPROPERTY( EditAnywhere, BlueprintReadWrite, Category = HUD ) FColoredTexture* Texture;
The UPROPERTY()
specified for the FColoredTexture
will show up in the editor as editable fields when included as UPROPERTY()
fields inside another class, as shown in step 3.
18.119.142.232