Any Object implementing an Interface as parameter

I’m not sure I understand what you want to do to be honest.

Given the example code you showed, you cannot just call that function on any random object. You can only call it on an object which implements the interface, and therefore you already have to know whether it implements it or not, and already have a reference to it. It’s no different in Blueprint.

Either way, both of these functions compiled fine for me - and gave me a node with an interface pin on the return. Obviously in this example the interface is null, in reality you would have to populate it with something.



UFUNCTION(BlueprintCallable, Category = "Test")
TScriptInterface<IHLLTeamInterface> GetTeamIFace() const { return TScriptInterface<IHLLTeamInterface>(); }

UFUNCTION(BlueprintNativeEvent, Category = "Test")
void GetTeamIFace(TScriptInterface<IHLLTeamInterface>& OutInterface) const;
void GetTeamIFace_Implementation(TScriptInterface<IHLLTeamInterface>& OutInterface) const { OutInterface = TScriptInterface<IHLLTeamInterface>(); }


1 Like