I have had some problems understanding how the interface system is supposed to be used. The UINTERFACE consists of two parts, “UMyInterface” and “IMyInterface”. From what I understand you must use the “UMyInterface” to safely store references/pointers to an interface, e.g. as an UProperty or a TWeakObjectPtr.
Now, how do you access the methods in “IMyInterface” from a pointer of type “UMyInterface”? I understand you can use InterfaceCast but must you really use a dynamic cast when you already know the type?
Thanks a lot for helping me understand how the UINTERFACE works.
I have had a lot of struggle understanding this. I also have some comments to EPIC about this. In terms of typesafety this is really dirty. It doesn’t only make the code more error prone and hard to read but also leads to a lot of code duplications in form of if clauses spread all over the application performing dynamic casts and checking for null. Even though it’s unlikely to lead to any major performance issues, it still has impacts on code quality.
I dont know exactly how IInterface works, and I am not sure what sort of answer you are looking for as to the details of its operation, I hope someone at Epic can answer this question about the inner workings of IInterface!
I’m having some trouble with this actually. I create a UInterface and IInterface of my own and implemented it within a blueprint. The UInterface is “Blueprintable”. But in the code whenever I try to cast that object it fails. “Actor->Implements()” works fine. But “InterfaceCast(Actor)” fails…