UEnum* FEnumEditorUtils::CreateUserDefinedEnum(UObject* InParent, FName EnumName, EObjectFlags Flags) { ensure(0 != (RF_Public & Flags)); UEnum* Enum = NewObject<UUserDefinedEnum>(InParent, EnumName, Flags); if (NULL != Enum) { TArray<TPair<FName, int8>> EmptyNames; Enum->SetEnums(EmptyNames, UEnum::ECppForm::Namespaced); Enum->SetMetaData(TEXT("BlueprintType"), TEXT("true")); } return Enum; }
UEnum* UJavascriptLibrary::CreateEnum(UObject* Outer, FName Name, TArray<FName> DisplayNames) { UEnum* Enum = NewObject<UEnum>(Outer,Name,RF_Public); if (NULL != Enum) { TArray<TPair<FName, uint8>> Names; int32 Index = 0; for (auto DisplayName : DisplayNames) { Names.Add(TPairInitializer<FName, uint8>(DisplayName, Index)); Index++; } Enum->SetEnums(Names, UEnum::ECppForm::Namespaced); } return Enum; }