Skip to content

Instantly share code, notes, and snippets.

@Delaunay
Last active July 28, 2024 18:21
Show Gist options
  • Save Delaunay/4d91143d5e8c7eca34adfe1e678499ab to your computer and use it in GitHub Desktop.
Save Delaunay/4d91143d5e8c7eca34adfe1e678499ab to your computer and use it in GitHub Desktop.
UnrealEngine C++ interface
UMyInterface::UMyInterface(const FObjectInitializer &ObjectInitializer):
Super(ObjectInitializer)
{
}
#include "UObject/Interface.h"
namespace utils {
inline bool ImplementsInterface(UObject* Object, UClass* Interface) {
return Object && Object->GetClass()->ImplementsInterface(Interface);
}
}
UINTERFACE()
class PROJECT_API UMyInterface : public UInterface
{
GENERATED_UINTERFACE_BODY()
};
class PROJECT_API IMyInterface
{
GENERATED_IINTERFACE_BODY()
//! BP Implementable
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category = "MyInterface")
UObject* GetObject();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment