UE4: Guidebook
4.25
4.25
  • Introduction
  • Quick Reference
    • C++ Data Type Snippets
    • The UPROPERTY Macro
    • The UFUNCTION Macro
  • Wiki Archives
    • Debugging & Utilities
      • Exec Functions
      • How To Prevent Crashes Due To Dangling Actor Pointers
      • Profiling: How to Count CPU Cycles
      • Logs: Printing Messages to Yourself during Runtime
    • Macros & Data Types
      • Structs, USTRUCTS(), They're Awesome
      • Enums For Both C++ and BP
      • Delegates in UE4, Raw C++, and BP Exposed
      • Interfaces in C++
      • Iterators
      • String Conversions: FString to FName, FString to Int32, Float to FString
    • Networking
      • Standalone Dedicated Server
      • How To Use Sessions In C++
      • Spawn Different Pawns For Players in Multiplayer
      • Spawn Different Pawns For Every Player
      • Gameplay Abilities and You
    • DevOps
      • Linking DLLs
    • AR & VR
      • Integrating OpenCV into Unreal Engine 4
Powered by GitBook
On this page
  • Interfaces
  • Structs

Was this helpful?

  1. Quick Reference

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.

PreviousQuick ReferenceNextThe UPROPERTY Macro

Last updated 5 years ago

Was this helpful?

Interfaces

For more information about interfaces in Unreal, .

  • 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.

UINTERFACE(BlueprintType)
class MYPROJECT_API UExample : public UInterface
{
  GENERATED_BODY()
};

class MYPROJECT_API IExample
{
  GENERATED_BODY()

public:

  UFUNCTION(BlueprintNativeEvent, BlueprintCallable)
  bool NativeEventExampleMethod();

  UFUNCTION(BlueprintImplementableEvent, BlueprintCallable)
  bool BlueprintEventExampleMethod();

};

Structs

  • 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.

USTRUCT(BlueprintType)
struct MYPROJECT_API FExample
{
    GENERATED_BODY()
    
public:

    UPROPERTY(BlueprintReadOnly)
    int32 SomeValue;

};

For more information about structs in Unreal, .

check out this wiki article
check out this wiki article