How can I use TMap for Inventory?

I was planning on implementing an abstract inventory class using a TMap to store items with their associated locations within the inventory, and expose them as readonly properties to blueprints. However, after adding the following UPROPERTY tag, it seems that I can’t use TMaps as properties:

UPROPERTY(VisibleAnywhere, BlueprintReadOnly, etc...)

The type would be something like this:

TMap<location_type, item_type> Items;

Is there any way to use a hashmap like this and expose it to a blueprint? I know I can implement it using a TArray, but not without creating a separate structure that stores an item’s locations within the inventory. And using a TArray seems kind of like a roundabout way of doing this.

Thanks for any tips!

You can’t expose TMap directly to blueprints as UPROPERTY. The same goes for TSet.

To work around it, you can create UFUNCTIONS for indirect use of your property in bluepeinrs.

Thanks, I’m currently implementing it using a TArray of a custom type that contains the location within the inventory instead. I guess I’ll have to do it that way. Thanks again!