Intelisense says it’s fine but on compile I get: C++ Default parameter not parsed: ScreensToClose “TArray()”
I’ve tried using the parameter as a reference but with the same result. I’ve seen some code that passes a TArray of AActor* with a default parameter just fine.
Do you use UFUNCTION here? Because this looks like UHT, not compiler error, it don’t know how to translate this to reflection system which is more limited then of what C++ can do. You would need to remove UFUNCTION() to do this.
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:
Standard procedure Epic uses in the UE4 itself is to separate the C++ version from the Blueprint version by creating the function twice. Basically like so: