Unreal's USTRUCT Specifiers page lists all of the core specifiers but a lot of the metadata specifiers that it lists are only usable with UCLASS.
This page attempts to be an exhaustive list of all the USTRUCT
specifiers, giving explanations,
sample code, screenshots and related links for each.
General Points
- Tags are case insensitive, but I would recommend sticking to the case example here for readability.
- Quotation marks are optional if the values does not have spaces. e.g.
someBool=true
is treated the same assomeBool="true"
. Again, for readability I would recommend using quotation marks only around string-type properties.
Blueprint Logic
Blueprint Type
Position:
Main
Type:
flag
USTRUCT(BlueprintType)
Setting this allows the struct to be added as a variable to Blueprints. To
expose a struct to blueprints with BlueprintReadOnly
,
the struct must be marked with BlueprintType
.
Exposes this struct as a type that can be used for variables in Blueprints.
Hidden By Default
Position:
Meta
Type:
flag
USTRUCT(meta=(HiddenByDefault))
Pins in Make and Break nodes are hidden by default.
Disable Split Pin
Position:
Meta
Type:
flag
Related:
USTRUCT(meta=(DisableSplitPin))
"Split Struct Pin" is an option available when right-clicking the return node
of a UFUNCTION
. It
is only available if all the variables within the struct are exposed to
blueprints, and if DisableSplitPin
is
not present in the USTRUCT definition.
Why you might want to use it is a more interesting question. The only example
of this being used in the codebase is with FGameplayTag
.
Gameplay tags are structs but only contain an FName
property that
is used as their ID. I suppose that DisableSplitPin
is
used because Epic wanted to discourage users from splitting the struct out
to FName
when it's
much more helpful to keep it as an FStruct
and use all
the helper functions within.
Indicates that node pins of this struct type cannot be split
USTRUCT(meta=(DisableSplitPin))
struct FGameplayTag
{
GENERATED_BODY()
UPROPERTY(VisibleAnywhere, Category = GameplayTags)
FName TagName;
};
Has Native Break
Position:
Meta
Type:
string (Function name)
Related:
USTRUCT(meta=(HasNativeBreak="abc"))
HasNativeBreak
lets
you specify a static UFUNCTION()
to use
instead of the default behavior when a user chooses "Break (Struct)"
By default all properties marked as BlueprintReadOnly
or
BlueprintReadWrite
would be present in the node. Defining a native break function can let you
customize what is present in that node.
Indicates that the struct has a custom break node (and what the path to the BlueprintCallable UFunction is) that should be used instead of the default BreakStruct node.
USTRUCT(BlueprintType, meta = (HasNativeBreak = "ExampleProject.CatHelperLibrary.BreakCatStruct"))
struct FCat
{
GENERATED_BODY()
public:
UPROPERTY()
FString Name;
UPROPERTY()
FLinearColor CoatColor;
UPROPERTY()
FString SecretPetName;
};
UCLASS()
class UCatHelperLibrary : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintPure, Category = "Cat", meta = (BlueprintThreadSafe))
static void BreakCatStruct(const FCat& Cat, FString& OutName, FLinearColor& OutCoatColor);
};
void UCatHelperLibrary::BreakCatStruct(const FCat& Cat, FString& OutName, FLinearColor& OutCoatColor)
{
OutName = Cat.Name;
OutCoatColor = Cat.CoatColor;
}
Has Native Make
Position:
Meta
Type:
string (Function name)
Related:
USTRUCT(meta=(HasNativeMake="abc"))
Similar to HasNativeBreak
,
HasNativeMake
allows you to specify a static
UFUNCTION()
to use
to create and fill the values of a struct, without having to make the values
within the struct BlueprintReadWrite
.
Indicates that the struct has a custom make node (and what the path to the BlueprintCallable UFunction is) that should be used instead of the default MakeStruct node.
USTRUCT(BlueprintType, meta = (HasNativeMake = "ExampleProject.CatHelperLibrary.MakeCatStruct"))
struct FCat
{
GENERATED_BODY()
public:
UPROPERTY()
FString Name;
UPROPERTY()
FLinearColor CoatColor;
UPROPERTY()
FString SecretPetName;
};
UCLASS()
class UCatHelperLibrary : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintPure, Category = "Cat", meta = (BlueprintThreadSafe))
static FCat MakeCatStruct(FString Name, FLinearColor CoatColor);
};
FCat UCatHelperLibrary::MakeCatStruct(FString Name, FLinearColor CoatColor)
{
FCat Cat;
Cat.Name = Name;
Cat.CoatColor = CoatColor;
return Cat;
}
C++
No Export
Position:
Main
Type:
flag
USTRUCT(NoExport)
"No autogenerated code will be created" means you don't need to write GENERATED_BODY
No autogenerated code will be created for this class; the header is only provided for parsing metadata.
Deprecated
Immutable
Position:
Main
Type:
flag
USTRUCT(Immutable)
Immutable is only legal in Object.h and is being phased out, do not use on new structs!.
Atomic
Position:
Main
Type:
flag
USTRUCT(Atomic)
This is listed in the official documentation but I can't find a single use of it inside the Unreal Engine codebase.
Indicates that this struct should always be serialized as a single unit. No autogenerated code will be created for this class; the header is only provided to parse metadata from.