[Feature Request] Additional default value support for UFUNCTION

Some datatypes used in UFUNCTION parameters apparently do not support default values.
For example:

	void AddSlotToGrid(FIntPoint InPosition = FIntPoint(0, 0));

Results in a build error that the default value could not be parsed.
The datatype FIntPoint and others like FIntVector are fully supported in Blueprints, so why would a default value not be?

Try this:

    UFUNCTION(BlueprintCallable, meta=(AutoCreateRefTerm="InPosition"))
    void AddSlotToGrid(const FIntPoint& InPosition);

Does that do what you want?

1 Like

formatting an FIntPoint as “const FIntPoint& InPosition” gives the same error. meta AutoCreateRefTerm was included while testing.

C++ Default parameter not parsed: InPosition “FIntPoint(0 ,0)”

Example of another function implementing that format:

UFUNCTION(BlueprintCallable, BlueprintPure = false, Category = "Grid", meta = (ToolTip = "", AutoCreateRefTerm="InSlotSize"))
	bool CanPlaceSlotAtPosition(FIntPoint InPosition, const FIntPoint& InSlotSize = FIntPoint(0 ,0)) const;

If you add meta=(AutoCreateRefTerm="InPosition"), you can just omit the FIntPoint(0,0) and let the default constructor handle it… I think :-D.

The goal is to set a default value in the parameter, which differs from what the default constructor sets. So if I want an FIntPoint(1, 1) I must be able to do this:

void SomeFunction(FIntPoint InPosition = FIntPoint(1, 1));

One case where this is useful is in a grid where a slot’s size defined as FIntPoint is X 1 Y1 by default since 0x0 does not make sense.

Requiring BP users to set up the input every time they call the function with a “make struct” node or by breaking the pin is not optimal at all, when a default input of FIntPoint(0, 0) is certain to result in error.

Ah, I see, that makes sense.

Some data types work just fine with UFUNCTION. bool, int32, FVector, so it must be some kind of missing support for the remaining data types.
For example, this works just fine:

UFUNCTION(BlueprintCallable, BlueprintPure = false)
  void Test(FVector InVar = FVector(1, 2, 3)) const;

The same method using FIntVector only works in the following format, without the specifiers BlueprintCallable and BlueprintPure:

void Test(FIntVector InVar = FIntVector(1, 2, 3)) const;