Unreal C++
Interfaces
Section titled “Interfaces”Mistakes
Section titled “Mistakes”When checking if an UObject implements an interface make sure to check against the
UInterface not the IInterfaceName
UINTERFACE(Blueprintable)class UCursorSamplerInterface : public UInterface{ GENERATED_BODY()};
class CURSORSAMPLER_API ICursorSamplerInterface{ GENERATED_BODY()}
From other class
const bool bImplements = Sampler->Implements<ICursorSamplerInterface>();
C++ only Interfaces
Section titled “C++ only Interfaces”Not used in blueprints and not implemented using blueprints
Unreal 5.5
I was having issue on Windows compiling an interface. The compiler was complaining about a missing definition on the .cpp file To solve this issue the functions should be declared as pure virtual
#pragma once
#include "CoreMinimal.h"#include "AdapterDataTypes.h"#include "UObject/Interface.h"#include "EntityComponentDataInterface.generated.h"
// This class does not need to be modified.UINTERFACE()class UEntityComponentDataInterface : public UInterface{ GENERATED_BODY()};
/** * */class ENTANGLED_API IEntityComponentDataInterface{ GENERATED_BODY()
// Add interface functions to this class. This is the class that will be inherited to implement this interface.public: virtual bool Initialize() = 0;
virtual const FBox& GetDataBounds() = 0; //!! Yes = 0};
Headers
Section titled “Headers”Declare function signature with pass by reference
Section titled “Declare function signature with pass by reference”UFUNCTION(BlueprintCallable) void AppendFieldDataByRef(UPARAM(ref) TArray<FEntangledExtended>& FieldArray, const FEntangledExtended& InValue);