I’m trying to retrieve the name of an enum type in a template.
I found TNameOf<T> which seems to be meant to achieve exactly this for seemingly all types known to the unreal reflection system, but it simply throws an assertion instead. What am I doing wrong here?
Sample code:
UENUM(BlueprintType)
enum class EMyUEnumType : uint8
{
One,
Two,
Three
};
FName name = TNameOf<EMyUEnumType>::GetName(); // Hits an assertion ("crashes")
Ive linked this before on another answer…
Rama did a good explanation about enums… if you wanna get enum name which is reflected…
Maybe this is the proper way or atleast a good starting point
Can you please provide an example based on that explanation by Rama on how to achieve what I am asking for? As it stands this right now this is not even an attempt to answer my question
I provided code samples of what I am looking for. Please use them
Looks like you didn’t understand my question. I’m looking for a way to retrieve “EMyUEnumType” from the type (and without macros) instead of having to pass it as a parameter myself.
well so you wanna return enum without know what enum is that?
thats impossible i thinkbecause compiler need to know what he need return unless you return UENUM…
You can return enum from string but you need to know exactly what enum type you want back or you can get any enum as byte.
Thank you for your suggestion, but once I have the stringified typename I’m already done with regard to this question. I’m looking for a way to ask the Unreal reflection system for the stringified name of a given actual type.
In other words: I do have
EMyUEnumType
and I want
FName(TEXT("EMyUEnumType"))
And I want to achieve this without macros on my side or entering the string myself. TNameOf looks like a template meant to achieve just that, but it seems not to work as I expected in current engine versions.