USTRUCT Specifiers - nullstar/SecondBrain GitHub Wiki
UCLASS Specifiers | UFUNCTION Specifiers | UPARAM Specifiers | UPROPERTY Specifiers
- USTRUCT(BlueprintType)
- USTRUCT(meta=(HiddenByDefault))
- USTRUCT(meta=(DisableSplitPin))
- USTRUCT(meta=(HasNativeBreak="abc"))
- USTRUCT(meta=(HasNativeMake="abc"))
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.
USTRUCT(meta=(HiddenByDefault))
Pins in Make and Break nodes are hidden by default.
"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;
};
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;
}
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;
}
"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.
Immutable is only legal in Object.h and is being phased out, do not use on new structs!.
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.
#Unreal #Specifiers