How to expose a Sorted Map of Arrays to blueprint

I have a class that extends UGameInstanceSubsystem
I want to use the Initialize function to populate a Sorted Map of Arrays to blueprint.

If I declare this in my .h file, my code compiles:

TSortedMap<FString, TArray<FString>> puzzlesByCategoryMap;

But, if I try to put a UPROPERTY in front of it:

UPROPERTY(BlueprintReadOnly)
TSortedMap<FString, TArray<FString>> puzzlesByCategoryMap;

I get an error:

Unable to find 'class', 'delegate', 'enum', or 'struct' with name 'TSortedMap'

Any idea how to do this?

TSortedMap is not supported as a UPROPERTY. Only TMap, TSet and TArray are the containers that are supported like this.

Option 1: Don’t declare it as a UPROPERTY. Since you don’t have any UObject*'s to keep alive you don’t have to declare it as a property. You’d have to write separate functions to work with it in from blueprint or to do any serialization.

Option 2: Use TMap instead. The one additional change you’d have to make will be to make a USTRUCT with a TArray as a member because UPROPERTY doesn’t support containers nesting each other directly.

Thanks for the info. I will have to re-think the way I am structuring my project.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.