BlueprintNativeEvent in an Interface Compiler Error

Kowbell
Mon, 12 Mar 2018 22:53:01 +0000
UI

I’m trying to add an UInterface in C++ that has a bunch of BlueprintNativeEvent functions, but cannot get it to compile no matter what. Given the following code:

SelectableInterface.h

#pragma once

#include "CoreMinimal.h"
#include "SelectableInterface.generated.h"

// This class does not need to be modified.
UINTERFACE(Blueprintable)
class USelectableInterface : public UInterface
{
	GENERATED_BODY()
};

/**
 *
 */
class GAMEJAM2018_VGDC_API ISelectableInterface
{
	GENERATED_BODY()
public:

	/**
	 * Called when the player selects/deselects this actor
	 * BlueprintNativeEvent, so you can override in Blueprints. Remember, in
	 *   C++ this means the .cpp file should only have
	 *   UpdateSelection_Implementation(...) !
	 */
	UFUNCTION(BlueprintNativeEvent, Category = "Selectable")
		void UpdateSelection(ESelectionState State = ESelectionState::Active);

};

SelectableInterface.cpp

#include "SelectableInterface.h"

void ISelectableInterface::UpdateSelection_Implementation(ESelectionState Type)
{
	UE_LOG(LogTemp, Error, TEXT("ISelectableInterface::UpdateSelection() not implemented/calls super!"));
}

I get the compilation error

SelectableInterface.h(34): error C2039: 'UpdateSelection_Implementation': is not a member of 'ISelectableInterface'
SelectableInterface.h(33): note: see declaration of 'ISelectableInterface'

with line 34 being the GENERATED_BODY() in ISelectableInterface.

I’ve tried not defining the function in .cpp at all, I’ve tried dropping _Implementation off the definintion, I’ve tried adding BlueprintCallable, I’ve tried overriding it in another class, I’ve tried a complete rebuild; each time, I still get the same error.

2 posts - 1 participant