Hi MrZelektronz,
First thing to note here is that in the code you posted, in the 2nd line of your function getName()
, the variable type is undefined (unless you have defined it somewhere else which is not posted in your original question). That aside, in order to get the name of an enum as a FString
you should do the followings:
- Make sure that your enums are defined in a way that Unreal Engine can understand them. Here’s two different way of defining Enums in an Unreal Engine friendly manner:
Note that they should be marked by the macro UENUM(/*Optional Specifiers*/)
. You can use any of these two versions and they will both work fine.
- Having defined your enums properly, you can get the name of your enums as a
FString
and print them to Ouput log screen as such:
See that static_cast difference between the two version of Enums for this case? You do not need to include anything for this code to work as long as you have CoreMinimal.h included in your header file. However if the intellisense still fails to catch up and keeps giving you false warnings, you can #include "UObject/Package.h"
in your .cpp file which should take care of these intellisense errors for you.
Hope this answered your question.