Making C++ Arrays with Structs more readable in Unreal Editor

Editing Arrays containing Structs in Unreal Engine has some bad UX. Especially for arrays with many entries as each element provides no context to its contents until you expand each element in the UI to inspect the contents. There is a way to make this look better using the TitleProperty meta-specifier! This trick is only available to arrays created in C++ that are exposed to be viewed in the Unreal Editor.

Defining the TitleProperty

Here is an example of a custom struct that contains the variable we wish to display in editor UI:

USTRUCT(BlueprintType)
struct FTeamInfo
{
	GENERATED_BODY();
public:
	/* Display name for Team in-game */
	UPROPERTY(EditAnywhere, BlueprintReadOnly)
	FText TeamName;

}

Now let’s add the TitleProperty to the array somewhere else in our code. We specify “TeamName” as that is the property we wish to display when viewing this array in the Unreal Editor.

UPROPERTY(VisibleAnywhere, meta = (TitleProperty = "TeamName"))
TArray<FTeamInfo> DefaultTeams;

The result of displaying this in the editor: (“Environment”, “Players”, “Pirates”, etc. are the TeamNames now embedded and visible even with the struct view collapsed. Without this specifier, the UI would be blank and you need to expand each element.

Example of the TeamName displayed in the array list.

That’s it! Now your arrays in the editor are far easier to read! It’s worth reading through the meta-specifier documentation as there are plenty of little tricks available. BenUI has recently created a UPROPERTY page to detail more of these nifty specifiers.

7 Responses

    • In respects to not adding this TitleProperty. If you’ve had to deal with structs in arrays then you’ll know how unreadable they get as you need to open up each property before you know their values. That’s the purpose of this TitleProperty.

  1. If I get this right, “TitleProperty = TeamName” is the Row and this will grab all data in that Row and set the Variables in that class?

    For instance I have a Struct called FQuest. I use the tag UPROPERTY(…, meta = (TitleProperty = “QuestName”)). With this as the FName, It will grab all data in that Row.

    Is the accurate? I ask, because I am building a Quest system through C++ and I am looking for an easy way so specify the Row to get all data of that Row. This sounds like it could be a viable option for the short term.

    • The TitleProperty is purely for making the variable value show up in the array view in the editor. It doesn’t change any functionality or ability to edit, just makes it easier to see your array visualized in-editor.

  2. I’m lost. Where is “TeamName” even appearing in that picture? Could you show an image that will allow me to compare with before and after? This article gives me nothing to see any positive benefit.

Leave a comment on this post!