Пример #1
0
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;
}
Пример #2
0
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;
}