Hello, I’m trying to put several enums into a separate namespace/header file so I can include the header in other classes and share the enum.
Enum File:
#pragma once
#include "CoreMinimal.h"
namespace MyEnumsNamespace
{
UENUM(BlueprintType)
enum class EPrimaryCategories : uint8
{
None UMETA(DisplayName = "None"),
Powers UMETA(DisplayName = "Powers"),
};
}
class MYPROJECT_API HUDEnums
{
public:
HUDEnums();
~HUDEnums();
};
Class trying to use them:
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/PlayerController.h"
#include "MyProject.h"
#include "HUDEnums.h"
#include "MainGamePlayerController.generated.h"
UCLASS()
class MYPROJECT_API AMainGamePlayerController : public APlayerController
{
GENERATED_BODY()
public:
AMainGamePlayerController(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get());
protected:
UFUNCTION(BlueprintCallable)
void SelectPrimaryCategory(MyEnumsNamespace::EPrimaryCategories Category);
}
The error I get is: Cannot find class ‘’, to resolve delegate ‘EPrimaryCategories’
This is what I know / have tried:
- If I remove the UENUM and UFUNCTION tags, everything works fine, though that is not an option because I need to expose this function to BPs.
- If I were to move this enum into the same class (minus the namespace) it would work fine.