Description

The current implementation of AutoCreateRefTerm does not allow for a default value to be automatically created for a TArray contained within a struct that is passed into a function as a parameter. It is possible to have a default for the entire struct created, but not for a specific TArray(s) within the struct. If the function is called in a Blueprint and the default Make node is used for the struct, any TArray input pins that do not have anything connected to them will cause the compilation to fail. The same result occurs if the struct input pin is split.

Steps to Reproduce
  1. Create a new basic code project.
  2. Add a new Actor code class to the project.
  3. In the new Actor class, create a USTRUCT(BlueprintType) that contains one or more TArray UPROPERTYs. Additional non-TArray UPROPERTYs are optional.
    • eg:
      USTRUCT(BlueprintType)
      struct FTestStruct
      {
      	GENERATED_BODY()
      
      	UPROPERTY(BlueprintReadWrite, meta = (DisplayName = "target List"))
      	TArray<class AActor*> targets;
      
      	UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = TestCat)
      	TArray<int32> TestVar;
      
      	FTestStruct() {};
      };
      
  4. Add a declaration and definition to the new class for a UFUNCTION(BlueprintCallable) that takes in the struct from the previous step as a parameter.
    • eg:
      UFUNCTION(BlueprintCallable, meta = (AutoCreateRefTerm = "InStruct"))
      static const int32 GetBestTarget(const FTestStruct& InStruct);
      
      const int32 AMyActor::GetBestTarget(const FTestStruct& InStruct)
      {
      	return 1;
      }
      
  5. Build the project in Visual Studio.
  6. Open the project in the Editor.
  7. Create a new Blueprint that derives from the new Actor class created in step 2.
  8. Open the Blueprint in the Editor.
  9. Place a node for the function created in step 4.
  10. Compile the Blueprint without connecting anything to the struct input pin.
    • The Blueprint compiles successfully since the AutoCreateRefTerm meta entry automatically creates a default for the struct input pin.
  11. Pull off of the struct input pin and place a Make node for the struct.
  12. Compile the Blueprint in the Editor without connecting anything into any TArray input pins.

RESULT:
The Blueprint fails to compile with an error showing for each TArray input pin. Eg. The current value of the ' Target List ' pin is invalid: Array inputs (like 'Target List') must have an input wired into them (try connecting a MakeArray node).

EXPECTED:
The Blueprint compiles successfully.

WORKAROUND:
Adding a HasNativeMake meta property to the USTRUCT allows the creation and use of a custom Make function for the struct, where AutoCreateRefTerm can be specified for each paramter.

Have Comments or More Details?

There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-55051 in the post.

0
Login to Vote

Fixed
ComponentUE - Gameplay
Affects Versions4.18.34.20
Target Fix4.25
Fix Commit12152178
Main Commit12152203
Release Commit12152178
CreatedFeb 9, 2018
ResolvedMar 12, 2020
UpdatedJul 30, 2020