I have a C++ actor interface:
UINTERFACE(MinimalAPI, Blueprintable)
class USpawnableCreature : public UInterface
{
GENERATED_UINTERFACE_BODY()
};
class ISpawnableCreature
{
GENERATED_IINTERFACE_BODY()
// Functions here
}
And a C++ CreatureSpawner class with this property:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TSubclassOf<USpawnableCreature> CreatureClass;
What I’m trying to achieve is that in the editor I can select CreatureClass from a dropdown menu of all C++ classes that implement ISpawnableCreature. So I’m only talking about C++ classes that implement the interface that are known at compile-time. What I’ve noticed is that you can’t do TSubclassOf. You will get this error:
'StaticClass' : is not a member of 'ISpawnableCreature'
I assume the type of TSubclassOf must inherit from UObject, which is why I’m now trying with USpawnableCreature. With this the code compiles and a drop down menu appears in the editor, except that its empty while I do have C++ that implement the interface. Does anyone know what I might be doing wrong? Is TSubclassOf possible with interfaces?
Some more things that I would like down the road. If anyone can shed some light on this that would be awesome:
- Can I get blueprint classes that inherit from a C++ class that implements ISpawnableCreature to appear in the dropdown?
- And how about blueprint classes that implement the interface themselves?