Hi everyone. I have a bunch of third party pure C++ interfaces which code should not be modified. Which would be the best way to convert or adapt them into unreal interfaces. I am looking for a solution where my interfaces are included into the unreal project and extended by the unreal interfaces/classes.
I’d just create a thin wrapper around the 3rd party interfaces.You could use a simple Pimpl pattern if you wanted.
UINTERFACE(MinimalAPI)
class U3rdPartyInterface : public UInterface
{
GENERATED_UINTERFACE_BODY()
};
class I3rdPartyInterface
{
GENERATED_IINTERFACE_BODY()
public:
// Thin wrapper around 3rd party lib.
void doWork() { Impl->doWork(); }
void doMoreWork(int a, int b) { Impl->doMoreWork(a,b); }
private:
3rdPartyDLL* Impl; // Instantiated as part of the constructor for I3rdPartyInterface
};
There’s a good thread on Interfaces here that goes into why you need UInterface as well as a more traditional C++ interface pattern.