i created a Tmap like so :
TMap<EStat, UStat*> CharacterStats;
where Estat is an enum and Ustat dervies from Uobject.
in the editor, when i try to add a new record to the map, i see the following:
i want to be able to set the values of UStat directly, and not assign a class to it.
i tried to decalare the TMap without a pointer (e.g TMap) and ofcourse it didnt compile.
how can i achieve my goal?
It looks like the site formatting obliterated the template data on your TMap above. Use the code formatting to prevent this from happening.
You should have something like this:
UPROPERTY(EditAnywhere, BlueprintReadOnly) TMap<EStat, UStat*> CharacterStats;
Your UEnum Key is working properly.
UStat* is a pointer to an existing UObject; it has to have been spawned before values can be adjusted.
You could spawn the needed objects in your Blueprint’s Construct method and store them in the TMap. You can set the proper values in the constructor after they’ve been spawned, or you can adjust them in the editor after the TMap has been populated.
As an alternative, you could create a UStruct that holds the values you want to change, and then store those in your TMap:
TMap<Estat, FUStatProperties> CharacterStas;
When you spawn the UStat object you can set the values by retrieving them from the appropriate UStruct.
thanks, i used a struct instead.
is there a general rule when it comes to deciding which to use?