I feel like, I’ve tried every possible combination of classes and meta attributes to have a soft object reference to an Actor, such, that the actor implements an interface.
I - personally - think all of those should either work or throw an error and to quote the Zen of Python:
There should be one – and preferably only one – obvious way to do it.
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TSoftObjectPtr<AActor> SomethingInstance;
The object picker in the Details panel shows a list of all Actors in the level.
works as intended
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (AllowedClasses = "StaticMeshActor"))
TSoftObjectPtr<AActor> SomethingInstance;
The object picker in the Details panel shows a list of all StaticMeshActor in the level. works as intended
now trying with the interface “Interactable”
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TSoftObjectPtr<IInteractable> SomethingInstance1;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TSoftObjectPtr<UInteractable> SomethingInstance2;
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (AllowedClasses = "Interactable"))
TSoftObjectPtr<AActor> SomethingInstance3;
SomethingInstance1 and SomethingInstance2 shows an AssetPicker (ContentDrawer, not Actors) and shows everything, regardless of the interface.
At least one of them should be an compiler error, tbh.
SomethingInstance3 shows an empty Asset Picker, though drag and drop does work.
This one should be the obviously working solution. Especially since drag and drop works.
one last try:
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (AllowedClasses = "AActor", MetaClass="Interactable", MustImplement = "Interactable"))
TSoftObjectPtr<AActor> SomethingInstance;
This just ignores MetaClass and MustImplement alltogether.
This should probably throw an errors upon compilation:
- MustImplement is only supported for TSubclassOf and TSoftClassPtr
- MetaClass is only used on non-templated types if at all.