I want to specify that when a certain UPROPERTY() is populated in Blueprints, it should be populated with the Asset ID for an Asset which is a Blueprint Class which implements a certain interface. (I’m declaring my interface as specified here, Interfaces in Unreal Engine | Unreal Engine 5.1 Documentation using both a UInterfaceName class and an IInterfaceName class.)
The way to do this when you want to constrain your UPROPERTY() to be populated with the Asset ID for an Asset which is a Blueprint Class which is the child of a certain class is:
TAssetSubclassOf<UClassName> PropertyName;
But when I try
TAssetSubclassOf<IInterfaceName> PropertyName;
the code doesn’t compile, and when I try
TAssetSubclassOf<UInterfaceName> PropertyName;
the dropdown of choices with which I populate the property is blank even though there are Blueprint Classes in my project which implement the interface.
First of all use TSubclassOf insted of TAssetSubclassOf, blueprint is same valid class as C++ and it should be treated same as any other C++ class in C++, or else you gonna have compatibility issues with your C++ and blueprint classes and you will be making different features for each. In general don’t treat code as asset but as classes, that why you trying this kind of gymnastics now ;p
Basically add “meta = (MustImplement = “MyInterfaceName”)” to the UPROPERTY macro of the property that needs to enumerate classes that implement a specific interface.