Can't use an engine enum

The reason of it failing is that in the declaration of this enum its not a Blueprinttype enum. Moreover its an old style enum that is no longer used and its declared as a namespace.

this is the declaration of the enum:

namespace EAsyncLoadingResult
{
	enum Type
	{
		/** Package failed to load */
		Failed,
		/** Package loaded successfully */
		Succeeded,
		/** Async loading was canceled */
		Canceled
	};
}

To use an enum in a UFUNCTION it must be declared as a enum class EEnumName : uint8 type.
In short: no, this enum cannot be used in UFUNCTIONS, maybe you can parse it into an enum declaration of your own that you might even use in blueprints.

Hope this helps. Make it a great day!

Hi everyone,

I’m struggling with a problem I think easy to fix.

I’m trying to use LoadPackageAsync(), but it requires a FLoadPackageAsyncDelegate.

This delegate is declared in UObjectGlobals.h like this :

DECLARE_DELEGATE_ThreeParams(FLoadPackageAsyncDelegate, const FName& /*PackageName*/, UPackage* /*LoadedPackage*/, EAsyncLoadingResult::Type /*Result*/)

My UFUNCTION is like this :

	// Delegate used when we will end a map precaching
	UFUNCTION()
		void PackageLoadedDelegate(const FName& PackageName, class UPackage* LoadedPackage, EAsyncLoadingResult::Type Result);    

Problem : I can’t compile because the compiler doesn’t seems to find the EAsyncLoadingResult

D:/UnrealProjects/AsyncMapLoading/Source/AsyncMapLoading/Public/AsyncLoader.h(58):
error : Cannot find class ‘’, to
resolve delegate ‘Type’

It looks like he’s looking for a class instead of the namespace. All right lets make a

using namespace EAsyncLoadingResult;

D:/UnrealProjects/AsyncMapLoading/Source/AsyncMapLoading/Public/AsyncLoader.h(60): error : Unrecognized type ‘Type’ - type must be a UCLASS, USTRUCT or UENUM

Did anyone succeed to use this enum inside a UFUNCTION ?

Best regards everyone,

Alexandre

PS : without the UFUNCTION it compiles well, but I need this MACRO because otherwise I can’t bind it.

Yeah I know for the enum in UFUNCTIONs, the problem it’s an enum located in the source of the engine and I use the binary release and build the engine from source just to add UENUM to it…

So for now I declared the same enum as a UENUM in my class, seems to work but Ugly As Hell.

But we agree it’s an error, this enum should be a UENUM especially with Async loads where you always have delegates.

Thanks :slight_smile: