Is there any way to have a blueprint exposed array of instanced interfaces?
I have a TArray of instanced objects that all share a parent class. I need to be able to add other types of objects to that array that only share UObject as a parent, but all implement the interface IFoo.
UCLASS(EditInlineNew)
class UA : public UObject, public IFoo {};
UCLASS(EditInlineNew)
class UB : public UA {};
UCLASS(EditInlineNew)
class UC : public UObject, public IFoo {}
------
UCLASS(BlueprintType)
class UBar : public UObject
{
//Old array I need to replace
UPROPERTY(EditAnywhere, Instanced)
TArray<TObjectPtr<UA>> arrayA;
//New array that should be able to instance objects of type UA, UB, or UC
UPROPERTY(EditAnywhere, Instanced)
TArray<IFoo*> arrayB;
// throws compiler error : 'Instanced' is only allowed on an object property, an array of objects, a set of objects, or a map with an object value type.
}
I need an array equivalent to TArray<IFoo*> that has has the UPROPERTY(Instanced) tag. The compiler doesn’t like TArray<IFoo*> since instanced can only work on an array of objects, even though everything that implements IFoo is an object.
What would be the best way to accomplish this?