Where Device - is the pointer on the UGunComponent (and I have checked if Device implements that interface). But I’m getting that kind of error:
C2039 ‘Execute_GetEnergyDisableDelegate’: is not a member of ‘IEnergyDeviceInterface’
I made some researches I and found an info, that Unreal macro-system doesn’t support pure virtual functions and I need to use PURE_VIRTUAL with some parameters in it. But since it’s a delegate, I can’t pass a nullptr on it.
You need to put UFUNCTION() on function deceleration of interface, otherwise UHT will ignore it and do add function to reflection system as well won’t generate Execute_* function for that function, thats why it say it’s not declared.
If UHT gives you any error then it means what you doing is not supported by UE4 reflection system. In that case you can make blueprint static function else where.
Note that if you use that interface only in C++ you don’t need to use Execute_* function as well as UFUNCTION() and just call function directly as all you need to do in C++ is add parent to class to implement interface, Execute_ is only to forward function call to Blueprint system as UE4 have no chance to intercept normal C++ function calls. It’s exact same issue as with events.
If I put UFUNCTION() on function declaration of interface, I’m getting the same error: “‘Execute_GetEnergyDisableDelegate’ is not a member of IEnergyDeviceInterface”. That means I’m not supposed to make it work via Execute_*, right?
No what im saying is if you UHT error then it means what you doing is not supported by reflection system. Execute_ should work with UHT passed your deceleration, if it processed at all. And that you can skip all that and just call interface function direclly if you plan to use this interface only in C++. What you getting is compiler error, which means UHT didnt generate code for the interface some reason