Useful specifiers for Blueprint - part 3
Here's yet another part of some specifiers useful for Unreal Engine's Blueprints nodes generate.
Previous parts can be found HERE and HERE
Naming output pins
In the previous part I showed how to name the output pins, but there are actually more ways of doing that if you are using return value instead of returning by reference.
UFUNCTION(BlueprintCallable)
void GetBoolResult(UPARAM(DisplayName = "MyBoolResult") bool& bResult);
UFUNCTION(BlueprintCallable)
UPARAM(DisplayName = "MyBoolResult") bool GetBoolResult();
UFUNCTION(BlueprintCallable, meta=(ReturnDisplayName="MyBoolResult"))
bool GetBoolResult();
Filtering objects
Sometimes you want to have an UPROPERTY that is set somewhere in Blueprints, but you want to filter it somehow to give a hint which assets can be used.
MustImplement
Says what Interface the given sublass (or soft class) must implement to be accepted here
UPROPERTY(EditAnywhere, meta=(MustImplement="MyInterface"))
TSubclassOf<AActor> SomeActorClass; // Must implement the IMyInterfaceAllowedTypes
Says that the FPrimaryAssetId must be of a given type
UCLASS()
class MYPROJECT_API UMyItem : public UPrimaryDataAsset
{
GENERATED_BODY()
public:
FPrimaryAssetId GetPrimaryAssetId() const override
{
return FPrimaryAssetId(TEXT("MyItemType", GetFName());
}
};
UPROPERTY(EditAnywhere, meta=(AllowedTypes="MyItemType"))
FPrimaryAssetId SomeAssetId; // Must be of type "MyItemType" (the UMyItem)
Categories
Says that you can use FGameplayTag or FGameplayTagContainer from a specific parent
UPROPERTY(EditAnywhere, meta=(Categories="My.Gameplay.Tag"))
FGameplayTag MyTag; // Must be My.Gameplay.Tag or a child of it, like My.Gameplay.Tag.X
RequiredAssetDataTags
Checks if the given asset has specific entry in Asset Registry. It is mostly used to check if the given DataTable uses the specific RowStructure.
UPROPERTY(EditAnywhere, meta=(RowStructure=/Script/MyProject.SomeRow)
class UDataTable* MyDataTable; // This data table must be made out of FSomeRow
But it can be also used to filter objects by any Asset Registry, for example a texture grou for Textures.
UPROPERTY(EditAnywhere, meta=(RequiredAssetDataTags = "LODGroup=TEXTUREGROUP_UI"))
class UTexture2D* MyUITextuer; // This texture must be in UI texture groupDefault values in Blueprint input pins
To set a default value in the input of BlueprintCallable function, you can set a default argument in c++:
UFUNCTION(BlueprintCallable)
void SomeFunction(bool bBoolParam = true);However, if you don't want to use C++ default arguments, but still set this parameter to be by default true in Blueprints, you can use it in meta properties.
UFUNCTION(BlueprintCallable. meta=(bBoolParam=true))
void SomeFunction(bool bBoolParam);Edit Conditions
Determines if the given property can be modified, or if it's grayed out and can't be modified.
EditCondition
If this condition is true, then you can edit this property in Blueprints. You can use just one bool like "bCanModify" or multiple ones "bCanModify&&!bCantModify" or even compare enums "RequiredType==ETypes::SomeType".
UPROPERTY(EditAnywhere)
bool bCanModify;
UPROPERTY(EditAnywhere, meta=(EditCondition="bCanModify"))
float ModifiableProperty;
EditConditionHides
Hides the property if can't be edit.
UPROPERTY(EditAnywhere, meta=(EditCondition="bCanModify", EditConditionHides))
float ModifiableProperty;
InlineEditConditionToggle
Hides the boolean flag and adds the toggle next to the property. Makes it more clear.
BEWARE! There is an issue with using it in the classes serialized to config files and exposed to the Project Settings.The bool flag is not serialized correctly.
UPROPERTY(EditAnywhere, meta=(InlineEditConditionToggle))
bool bCanModify;
UPROPERTY(EditAnywhere, meta=(EditCondition="bCanModify"))
float ModifiableProperty;
Other useful stuff
ForceInlineRow
Works with TMap. Instead of standard view, where keys are on top and values are under the keys, the Map entries are displayed with key on the left and value on the right column.
UPROPERTY(EditAnywhere, meta=(ForceInlineRow))
TMap<FGameplayTag, int32> TagsCounter;
CallInEditor
Makes the function callable by editor scripts. It also adds a button to a Details Panel when you select Actor instance with such function. The function can be called by pressing this button. Super convenient for some "regenerate" functions.
FUNCTION(CallInEditor)
void InEditorFunction();