Can Unreal C++ Interfaces inherit from other Unreal C++ Interfaces?

Hi, I am testing how much I can stretch the engine. I would like to create this kind of interface structure in Unreal 4:

44433-interfaces.png

Is it possible to make an interface inherit another interface? According to [this][2] thread yes but I did not manage to make it compile.

If it is not possible how would you go about creating this type of inheritance tree?

Thanks!

So I just tried this with 4.12.

I was able to have an Interface like so in C++…

UMyInterface2 : UMyInterface 1 {…}

//with an event in the parent and an event in the child.

…and that would compile, but if you go into the editor and create any blueprints (using BlueprintNativeEvent), and add the child interface, any time you try to compile that blueprint with the child event placed in the event graph, it will say that there is a node of the same name that exists already and won’t compile. This does NOT happen so long as you don’t try to actually create the child event and only reference the events that are native to the child. If you remove the child and add the parent interface, then it can compile with the parent event without issue.

I haven’t tried it yet with regular functions or in C++ yet. I suspect functions in BP would work the same way and not compile, but perhaps the C++ side won’t complain?

Just confirmed that the C++ side can see the _Implementation version of BlueprintNativeEvent-type inherited interface functions in a test actor that implements the child interface. The UE_LOG in ATestActor::OnAdd_Implementation successfully logs when called from its BeginPlay method.

UINTERFACE(NotBlueprintable)
class SPECTRAL_API UStorageComponentIntf : public UInterface
{
	GENERATED_UINTERFACE_BODY()
};

class SPECTRAL_API IStorageComponentIntf {

	GENERATED_IINTERFACE_BODY()

public:

	UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "StorageComponentIntf")
	void OnAdd();

	UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "StorageComponentIntf")
	void OnRemove();

};

-----

UINTERFACE(NotBlueprintable)
class SPECTRAL_API UCompositeStorageIntf : public UStorageComponentIntf
{
	GENERATED_UINTERFACE_BODY()
};

class SPECTRAL_API ICompositeStorageIntf {

	GENERATED_IINTERFACE_BODY()

public:

	UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "CompositeStorageIntf")
	EStorageName GetName();
};

----

UCLASS()
class SPECTRAL_API ATestActor : public AActor, public ICompositeStorageIntf
{
	GENERATED_BODY()
	
public:	
	// Sets default values for this actor's properties
	ATestActor();

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

	EStorageName GetName_Implementation();

	void OnAdd_Implementation();
};

---

EStorageName ATestActor::GetName_Implementation() {
    return EStorageName::SN_Skills;
}

void ATestActor::OnAdd_Implementation() {
    UE_LOG(LogTemp, Warning, TEXT("OnAdd_Implementation has triggered"));
    return;
}

Based on the fact that Blueprints may have trouble with this though, it may be that you will need to make every interface that is part of an interface inheritance hierarchy NonBlueprintable. You’d also likely need to prevent any blueprint objects from implementing those interfaces to avoid name collisions as detailed in my initial answer.