普通のC++と扱い方は同じですが、インターフェースクラスの生成だけ少し違います。

C++作成でUnreal Interfaceというので作成をします。

Untitled

こういうものが出来ます。

Untitled

CPPInterfaceTestではこのようにコードを記載します。

virtual void Print();以外は初期生成時に記載されます。

.h

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "UObject/Interface.h"
#include "CPPInterfaceTest.generated.h"

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

/**
 * 
 */
class CPP_UE_TEST_API ICPPInterfaceTest
{
	GENERATED_BODY()

	// Add interface functions to this class. This is the class that will be inherited to implement this interface.
public:
	virtual void Print();
};
.cpp

// Fill out your copyright notice in the Description page of Project Settings.

#include "CPPInterfaceTest.h"
#include "Kismet/KismetSystemLibrary.h"

// Add default functionality here for any ICPPInterfaceTest functions that are not pure virtual.

void ICPPInterfaceTest::Print()
{
	UKismetSystemLibrary::PrintString(
		NULL,
		TEXT("HELLo"),
		true,
		true,
		FColor::Cyan,
		10.f,
		TEXT("None")
	);
}

インターフェースクラスの準備は出来たので、利用したいクラスで呼び出して利用するだけです。

.h

#include "CPPInterfaceTest.h"

class CPP_UE_TEST_API ACPPActorTesttSpawn : public AActor, public ICPPInterfaceTest
.cpp

Print();