Hi, I defined some enums in BP and I want to use thats in c++.
For example I defined Classes Enums and I want to use this in c++ as
Classes CharacterClass;
How can I use that? Thanks a lot …
Hi, I defined some enums in BP and I want to use thats in c++.
For example I defined Classes Enums and I want to use this in c++ as
Classes CharacterClass;
How can I use that? Thanks a lot …
Enum in blueprint is like a asset so you need to get it like any other asset
It the same you just use UEnum insted of UMaterial
But even so compiler won’t acknowledge that enum as native C++ enum, it will be just a object of class for it which i matter of fact does not exist in compile time to read it, so generally if you want enum to be used in C++ it’s better and more comfitible to declare it in C++
Well,
(at least for me) this approach did not work.
What DID work tough is LoadObject:
UUserDefinedEnum* myenum = LoadObject<UUserDefinedEnum>(nullptr, TEXT("/Game/Sliders.Sliders"));
if (!myenum)
{
//UE_LOG("Invalid2"...
}
else
{
FText txt = myenum->GetDisplayNameTextByValue(3);
// txt contains text of enum which
// other functions can be found in uuserdefinedenum documentation
}