Unreal Snippet: Readable structure arrays

Structure arrays in Unreal Engine are obfuscated by default. The value for each array element displays the number of members contained within the structure, rather than use an identifiable value.

Unreal Snippet: Readable structure arrays

Structure arrays in Unreal Engine are obfuscated in the details panel by default. The value for each array element displays the number of members contained within the structure, rather than using an identifiable value.

Thankfully, there is a method to fix this. And unfortunately for some, this fix is currently only available via C++.


Want to discuss this article, Unreal Engine, or media in general? Head on over to the official Unreal Directive Discord server! We're looking to foster a helpful and fun community!


Unreal Engine allows something called Meta Specifiers to be appended to classes, interfaces, structs, enums, enum values, functions, and properties. In the case of Structure Arrays, appending the TitleProperty meta specifier to the UPROPERTY will allow it to become readable. Like so --

On the right, I designated the ItemName variable from the FItemData structure to be what is displayed. Now, when the set value changes in the structure, it will immediately reflect in the details panel. It's clear as day the difference the small addition makes!

Need further explanation? No problem!

/** 
* The information of the item.
*/
USTRUCT(BlueprintType)
struct FItemData
{
    GENERATED_BODY();

    /** The name of the item. */
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "General")
    FName ItemName;

    /** The description of the item. */
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "General")
    FText ItemDescription;

    //..
};

In this example, I have created a structure named FItemData with two variables – ItemName and ItemDescription. When I use this structure in an array, I will want the ItemName to be the identifier.

/**
* A Data Asset that holds the array
*/
UCLASS(ClassGroup=(Custom), meta=(BloueprintSpawnableComponent))
class UInventoryManager : public UActorComponent
{
    GENERATED_BODY()
    
    /** The items contained in the inventory. */
    UPROPERTY(EditAnywhere, Meta = (TitleProperty = "ItemName"))
    TArray<FItemData> Items;
    
    //..
};

Here, I have created an Actor Component named UInventoryManager with a singular variable – Items. Notice how I added the TitleProperty meta specifier with the value of ItemName to the definition.

What this does is designate the FItemData's ItemName variable as what to display in the details panel.


Additional Resources

Metadata Specifiers
Metadata keywords used when declaring UClasses, UFunctions, UProperties, UEnums, and UInterfaces to specify how they behave with various aspects of Unreal Engine and the editor

If you like the content and it has helped you, please consider supporting the development of the Unreal Directive.