Skip to main content

File layout & top-level constructs

A TPScript file begins with optional file-scope declarations, followed by top-level type declarations (uclass, class ... extends, ustruct, uenum, interface).

Includes​

Use include for any header your file needs:

include "CoreMinimal.h"
include "GameFramework/Actor.h"
include "TimerManager.h"

Both quoted ("...") and system (<...>) forms are allowed. Includes are emitted at the top of the generated .h file.

Comments​

// this is a line comment
/* this is also supported */

The log directive​

Declare a file-scope log category:

log MyGame severity Log verbosity All

This emits DECLARE_LOG_CATEGORY_EXTERN and lets you use UE_LOG(LogMyGame, ...) in your generated code.

forward​

Emit a raw forward-declaration line (e.g. to forward-declare a type before its usage):

forward class UMyThing;

declare (file-scope delegates)​

Define a delegate type at file scope so multiple classes can share it:

declare DynamicMulticast FExampleDoorOpened (OneParam APawn*, Opener)

See Delegates for the full syntax.

Top-level type declarations​

Every file must contain one or more of:

KeywordDeclares
uclass … : Basea low-level UCLASS (also class … extends … for the high-level form)
ustruct … (…)a USTRUCT
uenum …a UENUM (header-only)
interface …a UINTERFACE + I-interface pair

Low-level class​

uclass AMyActor : AActor meta: api=MYGAME_API
{
// members...
}

High-level class​

class my_actor extends actor meta: api=MYGAME_API
{
// members...
}
  • High-level snake_case names are auto-converted to PascalCase and prefixed according to the base type (see Classes).
  • You may mix high-level and low-level styles in the same file (or even mix member kinds within one class, though it's cleaner to pick one style per file).

What ends up in the header vs source​

  • Header (.h): includes, forward declarations, UCLASS/USTRUCT/UENUM/UINTERFACE declarations, UPROPERTY/UFUNCTION declarations, delegate declarations.
  • Source (.cpp): includes the generated header, method bodies, constructors, _Implementation bodies for native events.

Next: The type system.