Properties

Choose your OS:

Property Declaration

Properties are declared using standard C++ variable syntax, preceded by the UPROPERTY macro which defines property metadata and variable specifiers.

UPROPERTY([specifier, specifier, ...], [meta(key=value, key=value, ...)])
Type VariableName;

Core Data Types

Integers

The convention for integral data types is "int" or "uint" followed by the size in bits.

Variable Type

Description

uint8

8-bit unsigned

uint16

16-bit unsigned

uint32

32-bit unsigned

uint64

64-bit unsigned

int8

8-bit signed

int16

16-bit signed

int32

32-bit signed

int64

64-bit signed

As Bitmasks

Integer properties can now be exposed to the Editor as bitmasks. To mark an integer property as a bitmask, just add "bitmask" to the meta section, as follows:

UPROPERTY(EditAnywhere, Meta = (Bitmask))
int32 BasicBits;

Adding this meta tag will cause the integer to be editable as a drop-down list of generically-named flags ("Flag 1", "Flag 2", "Flag 3", etc.) that can be turned on or off individually.

GenericBitmask.png

In order to customize the bitflags' names, we must first create a UENUM with the "bitflags" meta tag:

UENUM(Meta = (Bitflags))
enum class EColorBits
{
    ECB_Red,
    ECB_Green,
    ECB_Blue
};

After creating this UENUM, we can reference it with the "BitmaskEnum" meta tag, like this:

UPROPERTY(EditAnywhere, Meta = (Bitmask, BitmaskEnum = "EColorBits"))
int32 ColorFlags;

Following this change, the bitflags listed in the drop-down box will take on the names and values of the enumerated class entries. In the example above, ECB_Red is value 0, meaning it will activate bit 0 (adding 1 to ColorFlags) when checked. ECB_Green corresponds to bit 1 (adding 2 to ColorFlags), and ECB_Blue corresponds to bit 2 (adding 4 to ColorFlags).

CustomBitmask.png

While enumerated types can contain more than 32 entries, only the first 32 values will be visible in a bitmask association in the Property Editor UI. Similarly, while explicit-value entries are accepted, entries with explicit values not between 0 and 31 will not be included in the drop-down.

Floating Point Types

Unreal uses the standard C++ floating point types, float, and double.

Boolean Types

Boolean types can be represented either with the C++ bool keyword or as a bitfield.

uint32 bIsHungry : 1;
bool bIsThirsty;

Strings

Unreal Engine 4 supports three core types of strings.

  • FString is a classic "dynamic array of chars" string type.

  • FName is a reference to an immutable case-insensitive string in a global string table. It is smaller and more efficient to pass around than an FString, but more difficult to manipulate.

  • FText is a more robust string representation designed to handle localization.

For most uses, Unreal relies on the TCHAR type for characters. The TEXT() macro is available to denote TCHAR literals.

MyDogPtr->DogName = FName(TEXT("Samson Aloysius"));

For more on the three string types, when to use each one, and how to work with them, see the String Handling documentation .

Property Specifiers

When declaring properties, specifiers can be added to the declaration to control how the property behaves with various aspects of the engine and editor.

Property Tag

Effect

AdvancedDisplay

Properties are in the advanced dropdown in a Details panel.

AssetRegistrySearchable

The AssetRegistrySearchable keyword indicates that this property and its value will be automatically added to the Asset Registry for any Asset class instances containing this as a member variable. It is not legal to use on struct properties or parameters.

BlueprintAssignable

Usable with Multicast Delegates only. Exposes the property for assigning in Blueprints.

BlueprintAuthorityOnly

This property must be a multicast delegate. In Blueprints, it will only accept events tagged with BlueprintAuthorityOnly.

BlueprintCallable

Multicast Delegates only. Property should be exposed for calling in Blueprint code.

BlueprintGetter = GetterFunctionName

This property specifies a custom accessor function. If this property isn't also tagged with BlueprintSetter or BlueprintReadWrite, then it is implicitly BlueprintReadOnly.

BlueprintReadOnly

This property can be read by Blueprints, but not modified. This operator is incompatible with the BlueprintReadWrite specifier.

BlueprintReadWrite

This property can be read or written from a Blueprint. This operator is incompatible with the BlueprintReadOnly specifier.

BlueprintSetter

This property has a custom mutator function, and is implicitly tagged with BlueprintReadWrite. Note that the mutator function must be specified, e.g. "BlueprintSetter=SetterFunctionName".

Category = TopCategory|SubCategory|...

Specifies the category of the property when displayed in Blueprint editing tools. Define nested categories using the | operator.

Config

This variable will be made configurable. The current value can be saved to the .ini file associated with the class and will be loaded when created. Cannot be given a value in default properties. Implies ReadOnly.

DuplicateTransient

Indicates that the variable's value should be reset to the class default value during any type of duplication (copy/paste, binary duplication, etc.).

EditAnywhere

Indicates that this property can be edited by property windows, on archetypes and instances.

EditDefaultsOnly

Indicates that this property can be edited by property windows, but only on archetypes. This operator is incompatible with the "Visible" tags.

EditFixedSize

Only useful for dynamic arrays. This will prevent the user from changing the length of an array via the Unreal Editor property window.

EditInline

Allows the user to edit the properties of the Object referenced by this variable within Unreal Editor's property inspector (only useful for Object references, including arrays of Object reference).

EditInstanceOnly

Indicates that this property can be edited by property windows, but only on instances, not on archetypes. This operator is incompatible with the "Visible" tags.

Export

Only useful for Object properties (or arrays of Objects). Indicates that the Object assigned to this property should be exported in its entirety as a subobject block when the Object is copied (for copy/paste) or exported to T3D, as opposed to just outputting the object reference itself.

GlobalConfig

Works just like Config except that you cannot override it in a subclass. Cannot be given a value in default properties. Implies ReadOnly.

Instanced

Object (UCLASS) properties only. When an instance of this class is created, it will be given a unique copy of the Object assigned to this variable in defaults. Used for instancing subobjects defined in class default properties. Implies EditInline and Export.

Interp

Indicates that the value can be driven over time by a Track in Matinee.

Localized

The value of this variable will have a localized value defined. Mostly used for strings. Implies ReadOnly.

Native

Property is native: C++ code is responsible for serializing it and exposing to Garbage Collection.

NoClear

Prevents this Object reference from being set to none from the editor. Hides clear (and browse) button in the editor.

NoExport

Only useful for native classes. This variable should not be included in the auto-generated class declaration.

NonPIEDuplicateTransient

The property will be reset to the default value during duplication, except if it's being duplicated for a PIE session.

NonTransactional

Indicates that changes to this variable value will not be included in the editor's undo/redo history.

NotReplicated

Skip replication. This only applies to struct members and parameters in service request functions.

Replicated

The variable should be replicated over the network.

ReplicatedUsing = FunctionName

The ReplicatedUsing tag specifies a callback function which is executed when the variable is updated over the network.

RepRetry

Only useful for struct properties. Retry replication of this property if it fails to be fully sent (e.g. Object references not yet available to serialize over the network). For simple references, this is the default, but for structs, this is often undesirable due to the bandwidth cost, so it is disabled unless this flag is specified.

SaveGame

This specifier is a simple way to include fields explicitly for a checkpoint/save system at the property level. The flag should be set on all fields that are intended to be part of a saved game, and then a proxy archiver can be used to read/write it.

SerializeText

Native property should be serialized as text (ImportText, ExportText).

SkipSerialization

This property will not be serialized, but can still be exported to a text format (e.g. copy/paste).

SimpleDisplay

Visible or editable properties appear in the Details panel and are visible without opening the "Advanced" section.

TextExportTransient

This property will not be exported to a text format (e.g. copy/paste).

Transient

Property is transient, meaning it will not be saved or loaded. Properties tagged this way will be zero-filled at load time.

VisibleAnywhere

Indicates that this property is visible in all property windows, but cannot be edited. This tag is incompatible with the "Edit" tags.

VisibleDefaultsOnly

Indicates that this property is only visible in property windows for archetypes, and cannot be edited. This tag is incompatible with "Edit" tags.

VisibleInstanceOnly

Indicates that this property is only visible in property windows for instances, not for archetypes, and cannot be edited. This tag is incompatible with "Edit" tags.