C++ Data Type Snippets
This page contains several code snippets for quickly creating C++ data types that can be used with Blueprints. Use this as reference or as a copy + paste resource as needed.

Interfaces

For more information about interfaces in Unreal, check out this wiki article.
  • You need to define two classes: U<Name> and I<Name>. The second class is what your C++ code will extend to implement the interface.
1
UINTERFACE(BlueprintType)
2
class MYPROJECT_API UExample : public UInterface
3
{
4
GENERATED_BODY()
5
};
6
7
class MYPROJECT_API IExample
8
{
9
GENERATED_BODY()
10
11
public:
12
13
UFUNCTION(BlueprintNativeEvent, BlueprintCallable)
14
bool NativeEventExampleMethod();
15
16
UFUNCTION(BlueprintImplementableEvent, BlueprintCallable)
17
bool BlueprintEventExampleMethod();
18
19
};
Copied!

Structs

For more information about structs in Unreal, check out this wiki article.
  • To access your struct from Blueprint, make sure to add the BlueprintType keyword to the USTRUCT macro.
  • Structs must have a default constructor.
  • It's Unreal coding standard to prefix your structs with a capital F.
  • You cannot use the UFUNCTION macro with methods on structs.
1
USTRUCT(BlueprintType)
2
struct MYPROJECT_API FExample
3
{
4
GENERATED_BODY()
5
6
public:
7
8
UPROPERTY(BlueprintReadOnly)
9
int32 SomeValue;
10
11
};
Copied!
Copy link