Thanks for the response @GRIMTEC ! I use legal loosely to imply the behaviour will be what we expect (no crashes, null due to casts, and expected function overrides being called).
So assuming the interface pointer isn’t null, you can just seamlessly cast between an interface pointer and the concrete UObject pointer, right? Common C++ sense tells me that’s fair game.
As for Execute_Foo, is your statement applicable to both BlueprintImplementableEvent and BlueprintNativeEvent? If Foo was a BlueprintNativeEvent, and implemented by some class defined in C++, will calling MyInterface->Foo()
work - i.e it would execute the C++ implementation OR the BP implementation if overriden.
As for the last point, it helps to emphasize why I needed TScriptInterface. In my native code, I will be passing interface pointers around in the same manner you pass around a base class. But at some point, there will be a class that need to store a variable of type MyInterface*
- effectively owning the Object. But in order to keep UObjects from being GC’ed, you need the UPROPERTY()
markup, and that doesn’t work with an interface pointer. That’s where TScriptInterface comes in. What I am getting from this answer is that I am free to pass around the raw MyInterface*
around like typical C++ code, but wherever I need to claim ownership of the underlying object, I will need to use TScriptInterface
in conjunction with UPROPERTY
.