Useful specifiers for Blueprint nodes generation

Here I wanted to show you some useful UE4 specifiers used in functions, properties and classes declarations which helped me writing cleaner and more user friendly code and BP nodes. 

ExposeOnSpawn

When you add ExposeOnSpawn meta value to a property this property can be set in the Spawn Actor node
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ExposeOnSpawn = "true"))
int32 ExposedInteger = 0;


AutoCreateRefTerm

When you have a function parameter which is e.g. a structure or an array you must provide a value to this parameter's pin. Otherwise BP compiler will greet you with this error:


You can either connect the input pin to an empty MakeArray node (as the error suggest), or you can add a proper meta value:
UFUNCTION(BlueprintCallable, meta = (AutoCreateRefTerm = "Array"))
void TestArray(const TArray<int32>& Array);
This will automatically create an empty array if the pin in the node is not connected to anything.


BindWidget

Usually when we want to get a pointer to an UMG widget we must find it first:
if (UTextBlock* TextToDisplay = Cast<UTextBlock>(GetWidgetFromName("TextToDisplay")))
{
    TextToDisplay->SetText(FText::FromString("Hello!"));
}
However, this can lead into a problem when someone accidently rename or delete this widget and no one will notice it. But, if you define a widget with a proper meta:
UPROPERTY(meta = (BindWidget))
UTextBlock* TextToDisplay;
an error will occur:


Giving us an information, that the following widget is required.

This will also give us easier access to this widget as we already have it bounded into this property and GetWidgetFromName is no longer needed.


Instanced

Consider we want to create an object. Usual approach is to have an information about an object's class and a pointer to the created object.
 // .h
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TSubclassOf<UMyObject> MyObjectClass = nullptr;

UPROPERTY(transient)
UMyObject* MyObject = nullptr;

// .cpp
if (MyObjectClass)
{
    MyObject = NewObject<UMyObject>(MyObjectClass);
}
But, if the class of the object we want to create has editinlinenew property:
UCLASS(editinlinenew)
class MYPROJECT_API UMyObject : public UObject
we can make it being instanced:
UPROPERTY(EditAnywhere, BlueprintReadWrite, instanced)
UMyObject* MyObject = nullptr;
Thanks to this the object can be automatically created in the actor or the object that creates it! We can also setup it's public properties:


ExpandEnumAsExecs

This meta allows us to create multiple execs comming out from the function node. It requires an enum which will represent exec ids:
ENUM(BlueprintType)
enum class EExecType : uint8
{
    ET_Type1,
    ET_Type2,
    ET_Type3
};
UFUNCTION(BlueprintCallable, meta = (ExpandEnumAsExecs = "Exec"))
void MultipleExecsFuncion(EExecType& Exec);
The following core will produce such a node:


Multiple outputs

To make a function that will have multiple outputs simply pass function parameters as references:
UFUNCTION(BlueprintCallable)
void MultipleOutputsFunction(int32& Out1, int32& Out2, int32& Out2);
Thil will produce a following node:


Pass by reference

If the above code generates a node with multiple outputs how to generate a node with input arguments passed by reference? We need one extra macro:
UFUNCTION(BlueprintCallable)
void FunctionWithRefs(UPARAM(ref) int32& Ref1, UPARAM(ref) int32& Ref2, UPARAM(ref) int32& Ref3);
This will produce a following node:


Conclusion

I hope these little tricks will help you too! Cheers!