How to set up an array of structs as a property that's editable per instance?

I’ve configured a property like this:


UPROPERTY(EditAnywhere, BlueprintReadWrite)
TArray<FStructType> VariableName;


Where FStructType is a struct:


USTRUCT(BlueprintType, Blueprintable)
struct FStructType
{
    GENERATED_BODY()

    UPROPERTY(EditAnywhere, BlueprintReadWrite)
    USomeObject* SomeObject;
    UPROPERTY(EditAnywhere, BlueprintReadWrite)
    UWidget* SomeWidget;
};


However, when I try to assign values to an element of the array in the property editor, it doesn’t let me do it. The dropdown is populated properly but upon clicking the assignment fails. This is while editing the property in an instance of a UMG widget:
20200128_162718.gif

The problem is in PropertyHandleImpl.cpp, FPropertyHandleObject::SetValue(), where there is a check that the property doesn’t have the flag EditInlineNew, and if so the assignment fails.

I believe the flag is set by the EditAnywhere specifier, but without it the values are not available for edit in the instance.

If I forget the struct and have instead two arrays, one for each UObject type, then it works as expected.

Is there any way to get this to work?

Try:

  1. Adding the EditInlineNew specifier to your desired UCLASS (such as USomeObject)
  2. And then, add the Instanced specifier where you use the UCLASS as a property


// USomeObject definition
UCLASS(EditInlineNew)
class USomeObject : UObject ...

// USomeObject property
USTRUCT(BlueprintType, Blueprintable)
struct FStructType
{
    GENERATED_BODY()      

    UPROPERTY(EditAnywhere, BlueprintReadWrite, Instanced)    
    USomeObject* SomeObject;    
    UPROPERTY(EditAnywhere, BlueprintReadWrite)
    UWidget* SomeWidget;
};


I hope it’s alright to bump an older topic, however after hours of research I have not found a solution for this. I tried Mowgl33’s suggestion, but no luck, the behaviour has not changed.

Is it possible to have an array of structs as a property that allows per instance edits?

I’ve found many topics about this, but no concrete solution.

I’m really not sure what you mean? Are you not able to create a struct that’s modifiable in the editor? I’ve had no issues doing this on my end but with a different method.

I initially learned how to use Structs in UE4 C++ from this tutorial:

Hope it helps.

Thank you for the video link, I did reference it during my research but I couldn’t solve this issue.
It’s very close to the OP, I have an array of structs where each struct holds a custom class object and an int. It’s set as an instance editable property, but trying to assign the object from the dropdown list just resets it back to None. I hope this makes sense, having trouble describing issues due to being new + not native english.

Thank you for your response though, I do appreciate it :pray:

Instanced as should be expected, should not work within structs because several reasons.

They are passed around as value types and instanced objects in them should not be allowed.

The parent container type for instanced UObject must be a subclass of UObject itself.

Thank you, that makes sense.

Were you able to get it to work?