TMap with Key/Value UserWidget pointers lose references on Compile
I have a UserWidget subclass with a TMap UPROPERTY where the key and value are both UUserWidget pointers (ie TMap). After creating a BP instance of my widget, the inspector lets me properly assign to the map without issue, showing the correct available widgets in the Hierarchy. If I save the Widget in the editor, those values persist. However, if I Compile the blueprint, I'll lose the values every time, and all the Map entries will be empty.
asked Aug 06 '18 at 05:50 PM in C++ Programming
I'm afraid you can not use UUserWidgets as keys, you could try to generate a unique ID as your key and the value could contain a struct holding your pair (or even TPair).
To define your own keys what you normally do is to define how to compare your keys calsses and create a MapKeyFunction that the TMap will use to compare one to another.
The following is an example that you could follow:
The code above is written out of my head so it might need some love ^^
answered Aug 06 '18 at 10:00 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here