Course contentsShow
← Unreal Engine Game Development
Lesson 28 of 8801. Foundations and Editor WorkflowFree lesson

Understanding Unreal Reflection System Architecture

Learn how the Unreal Header Tool generates metadata to enable runtime type information and automatic property serialization for your classes.

In this lesson, you will learn how the Unreal Header Tool (UHT) creates the "metadata" necessary for the engine to understand your C++ code at runtime.

The Problem: C++ is a "Black Box"

Standard C++ is a static language. Once you compile your code into machine instructions, the original variable names, class structures, and properties essentially disappear from the program's perspective. However, Unreal Engine needs to "see" your code to handle things like automatic garbage collection, serializing data to disk, or exposing variables to the Editor’s Details Panel.

Because C++ doesn't provide this "Reflection" natively, Unreal creates its own.

How UHT Builds the Bridge

When you compile your project, the Unreal Header Tool (UHT) runs before the compiler. It scans your header files for special macros like UCLASS(), UPROPERTY(), and UFUNCTION().

Think of UHT as a librarian who reads your code before it is packed into a crate. It takes notes on every variable and function you’ve marked with a macro and generates a "manifest" (a hidden, auto-generated .generated.h file).

Consider this snippet:

UCLASS()
class AMyActor : public AActor
{
    GENERATED_BODY()

public:
    UPROPERTY(EditAnywhere)
    float Health;
};

When UHT sees UPROPERTY(), it logs the existence of Health into a metadata database. During runtime, the engine looks at this database to see that Health exists as a float. Because of this, the engine can automatically:

  1. Serialize: Save the value of Health to a .uasset file.
  2. Inspect: Draw an input field for Health in the Editor Details panel.
  3. Manage Memory: Track if Health is being used by another object.

Without UHT, the engine would see your float Health simply as a raw memory address, having no idea that it represents a gameplay value that needs to be saved or edited. The Reflection System is effectively the "interpreter" that bridges the gap between raw C++ code and the interactive, user-friendly nature of the Unreal Editor.

Key Takeaway: The Unreal Header Tool acts as a pre-compiler that generates metadata, allowing the engine to inspect and manipulate your C++ objects while the game is running.