Default Parameters with TArrays

You can use the AutoCreateRefTerm macro to do this. In the example below, MyOptionalParam will be given an empty array if non is provided via Blueprints.

UFUNCTION(BlueprintCallable, meta = (AutoCreateRefTerm = "MyOptionalParam"))
void MyFunction(TArray<AActor*> MyOptionalParam);

You can make multiple parameters have default values by putting multiple parameter names in the AutoCreateRefTerm string, separated by commas:

UFUNCTION(BlueprintCallable, meta = (AutoCreateRefTerm = "MyOptionalParam1,MyOptionalParam2"))
void MyOtherFunction(TArray<AActor*> MyOptionalParam1, TArray<AActor*> MyOptionalParam2);
4 Likes