Download

Why is my UPROPERTY actor pointer being denied access?

I’ve got 2 extremely bare bones C++ classes
DungeonComponents (Parent: Actor)
DungeonComponentInterfaceClass (Parent: UserWidget)

DungeonComponents.h is LITERALLY nothing but the standard generated code.


#pragma once

#include "GameFramework/Actor.h"
#include "DungeonComponents.generated.h"

UCLASS()
class DUNGEN_API ADungeonComponents : public AActor
{

	GENERATED_BODY()
	
public:	
	// Sets default values for this actor's properties
	ADungeonComponents();

	// Called when the game starts or when spawned
	virtual void BeginPlay() override;
	
	// Called every frame
	virtual void Tick( float DeltaSeconds ) override;

DungeonComponentInterfaceClass.h is barely more than that:


#pragma once

#include "DungeonComponents.h"
#include "Blueprint/UserWidget.h"
#include "DungeonComponentInterfaceClass.generated.h"

/**
 * 
 */

UCLASS()
class DUNGEN_API UDungeonComponentInterfaceClass : public UUserWidget
{
	GENERATED_BODY()
public:
	UDungeonComponentInterfaceClass();
	UFUNCTION(BlueprintCallable, Category = "DunGen") void SpawnSpecifiedComponent();
	UPROPERTY(EditAnywhere) ADungeonComponents* DungeonComponentToSpawn;	
};

If it’s not readily apparent, the UDungeonComponentInterfaceClass will be used to determine which component to spawn into the world. I’m trying to create a UPROPERTY that will give me a list of ADungeonComponents actors to choose from. Not a single godforsaken and/or damnedable thing is set to private… yet trying to compile this extremely barebone code throws up:

\DungeonComponentInterfaceClass.cpp(10) : error C2248: ‘ADungeonComponents::ADungeonComponents’: cannot access private member declared in class ‘ADungeonComponents’
\Public\DungeonComponents.h(12) : note: see declaration of ‘ADungeonComponents::ADungeonComponents’
\Public\DungeonComponents.h(9) : note: see declaration of ‘ADungeonComponents’

There are no private members in ADungeonComponents, the constructor is not private, it’s not even edited in the slightest…

I’m at an absolute loss.

Could be simple but, shouldn’t:



DUNGEN_API


be:



DUNGEON_API


Also, I would recommend using the ObjectInitializer version of constructors. Custom ones seem to have loads of problems when using anything other than a UObject. Example:

Header



AMyClass(const FObjectInitializer& OI);


CPP



AMyClass::AMyClass(const FObjectInitializer& OI) : Super(OI)
{}