Use of Execute_Prefix for Interfaces
I have a general questions about Interfaces. When reading through the documentation and epics wiki I see that a call to the interface should be by using Execute_Prefix.
Since I am not getting it to work with Execute_Prefix I just went head and trialed and errored a bit until i implemented it in this way:
Now it works it calls the right interface and I see why but for some reason I feel a bit unsure if I still should try to get it to work wit Execute_Prefix.
Maybe someone could clarify it.
You are sure you properly declared interface with UINTERFACE(), UIdentityActorComponentDataInterface class and GENERATED_BODY() on both I and U class? Considering Execute_ don't work and you don't get assert fail on execution of normal function, means there might be problem in decleration.
Now what you do will indeed work, it still 100% correct in C++ (in fact it is not interface, C++ simply supports multi-parent classes, which can work like interface, UE4 does not support that with UObjects), but you compliantly bypassing enigne management over it, engine don't see that interface and don't see being any functions being called. Reason behind Execute_ function is to make interface work in blueprint, if you gonna directly call interface function in C++ the call won't be forward up to blueprint system, it will only execute code in C++. So what you doing will work in C++, but won't work in blueprint, there also potential of some errors by using interface like that, because again what you have is caused by UE4 not adding this interface in reflection system so engine have 0 idea of this interface and functions existence.
Remember that regardless of people calling it "UE4 C++" it is still normal C++ and all C++ code incompatible with UE4 APIs will build and work, but if you not going to be careful with it you will get errors and crashes.
Follow this question
Once you sign in you will be able to subscribe for any updates here