Last active
August 16, 2024 22:54
-
-
Save AndreaCatania/732a549f53cf8832dc5012502f07370c to your computer and use it in GitHub Desktop.
How to modify Enum names at runtime in Unreal Engine 5 and Unreal Engine 4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Define your enum as usual inside an Header file. | |
UENUM() | |
enum class EMyEnums : uint8 | |
{ | |
MyEnum1, | |
MyEnum2, | |
MyEnum3, | |
MyEnum4, | |
MyEnum5, | |
}; | |
// NOTICE: You can use the following code inside any function. | |
// Fetch the Enum class object that contains the metadata associated to each enum | |
UEnum* Enum = StaticEnum<EMyEnums>(); | |
// Hide all enum properties | |
for (int EnumIndex = 0; EnumIndex < Enum->NumEnums(); EnumIndex++) | |
{ | |
Enum->SetMetaData(TEXT("Hidden"), TEXT("true"), EnumIndex); | |
} | |
// Change the enum display name and make it visible | |
Enum->RemoveMetaData(TEXT("Hidden"), 0); | |
Enum->SetMetaData(TEXT("DisplayName"), TEXT("ThisIsAnEnumUnrealName"), 0); | |
Enum->RemoveMetaData(TEXT("Hidden"), 1); | |
Enum->SetMetaData(TEXT("DisplayName"), TEXT("ThisIsAnEnumRealName"), 1); | |
Enum->RemoveMetaData(TEXT("Hidden"), 2); | |
Enum->SetMetaData(TEXT("DisplayName"), TEXT("ThisIsAnEnumFloatName"), 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hello , this is verry helpfull if it will work
but i am so bad in c++ can you please make is useable as blueprint function ,so make it as BP_FunctionLirary