TSubClassOf with Interfaces isn't working

I have the following c++ interface

class UActionInterface : public UInterface

class IActionInterface

I am then implementing this interface via my c++ weapon class

UCLASS(ABSTRACT, Blueprintable)
class FPSGAME_API AFPSWeapon : public AActor, public IActionInterface

I then create a Blueprint from this FPSWeapon and add the ActionInterface under the Interfaces section.

My Character c++ class has the following property

// Default Inventory List
UPROPERTY(EditDefaultsOnly, Category = Inventory)
TArray<TSubclassOf<IActionInterface>> DefaultInventoryClasses;

But now in the editor I get nothing for this dropdown instead of the shotgun bp like I would expect.

Does anyone know why my Shotgun BP doesn’t show up here?


Interfaces are not identify as UClass* so TSubclassOf (which work the same as UClass* just limiting the UClass selection i editor) won’t work either.

Use this insted


So I can’t limit the TSubclassOf dropdown to only my interface?

use UActionInterface insted of UInterface, but keep in mind those are like class identificators, not object pointers and i don’t know if you can do anything with those in blueprints.

Yeah even with TArray< TSubclassOf< UActionInterface > > DefaultInventoryClasses; I still get nothing in the dropdown box.

Ok i think i get it now you want list of objects that implements interface, i dont think there is anyway to do so. If you can find node in engine that is example of that i can find how it was made for you

Yeah, I am expecting to see my Shotgun BP in the dropdown box since it implements the interface. Is that not reasonable?

HA! Found it ^^ I digged a little in UHT code and find TScriptInterface

Try using I class if this wont work try using U class of interface

USe I class i found example in engine source code, i modified anwser, tell me if it works

When I use that I don’t get a dropdown at all.


I was able to get the following working. But now I’m interested in TScriptInterface.

UPROPERTY(EditDefaultsOnly, meta = (MustImplement = "ActionInterface"))
TArray<TSubclassOf<UObject>> DefaultInventoryClasses;
1 Like

Ah ok :slight_smile: Well then as you anwser to your quastion yourself i will turn it in to anwser and mark as resulved. I guess that template i told you is not supported by blueprints

Thank you!

What is that a TArray of?

Should it be UObjects:

TArray<UObject*> DefaultInventoryClasses;

Sorry not sure how that got chopped off before. I’ve edited my answer with how I have it.

Both of these worked for me:

UPROPERTY(EditDefaultsOnly, config, NoClear, Category="SomeCategory", meta=( MustImplement=SomeInterface ))
TSubclassOf<UObject> SomeVariable;

UPROPERTY(EditDefaultsOnly, config, NoClear, Category="SomeCategory", meta=( MustImplement=SomeInterface ))
UClass* SomeVariable;

I did this in a UDeveloperSettings so I had more restrictions about what kinds of variables were allowed (hence config and NoClear).