# TArray of UStruct of dynamic size as an editable UProperty

**URL:** <https://forums.unrealengine.com/t/tarray-of-ustruct-of-dynamic-size-as-an-editable-uproperty/287675>\
**Category:** Editor Scripting\
**Tags:** UProperty, tarray, ustruct, UClass, unreal-engine, dynamic, question\
**Created:** [July 8, 2014, 5:05pm UTC](https://forums.unrealengine.com/t/tarray-of-ustruct-of-dynamic-size-as-an-editable-uproperty/287675 "2014-07-08T17:05:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_de292077](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_de292077](https://forums.unrealengine.com/u/anonymous_user_de292077)\
**Post date:** [July 8, 2014, 5:05pm UTC](https://forums.unrealengine.com/t/tarray-of-ustruct-of-dynamic-size-as-an-editable-uproperty/287675/1 "2014-07-08T17:05:46Z")

</div>

I’d like to use a TArray of a UStruct as an editable UProperty in Blueprint. Like so.

```
USTRUCT()
struct FSomeStruct()
{
    float thingToEdit;
}

UCLASS()
class ASomeClass()
{
   UPROPERTY(Editanywhere...etc)
   TArray<SomeStruct> Structs;
}

```

The current issue I’m having is that when create a Blueprint from SomeClass and go to add a struct to the array in the Defaults pane is comes up with 0 elements. I’d like for it to add a new element to the array dynamically and allocate it at that time. Is this possible?

---

<div class="post-metadata">

**Author:** ![essbuh](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@essbuh](https://forums.unrealengine.com/u/essbuh)\
**Post date:** [July 8, 2014, 6:03pm UTC](https://forums.unrealengine.com/t/tarray-of-ustruct-of-dynamic-size-as-an-editable-uproperty/287675/2 "2014-07-08T18:03:21Z")

</div>

Completely possible - you just need to make sure your struct’s properties also have a UPROPERTY() with EditAnywhere, EditDefaultsOnly, etc. as well in order for them to show up in the editor.

---

<div class="post-metadata">

**Author:** ![Shadowriver](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Shadowriver](https://forums.unrealengine.com/u/Shadowriver)\
**Post date:** [July 8, 2014, 6:11pm UTC](https://forums.unrealengine.com/t/tarray-of-ustruct-of-dynamic-size-as-an-editable-uproperty/287675/3 "2014-07-08T18:11:44Z")

</div>

Yes by default (you can disable that) you should have + symbol to add element to array

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_de292077](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_de292077](https://forums.unrealengine.com/u/anonymous_user_de292077)\
**Post date:** [July 9, 2014, 9:37pm UTC](https://forums.unrealengine.com/t/tarray-of-ustruct-of-dynamic-size-as-an-editable-uproperty/287675/4 "2014-07-09T21:37:01Z")

</div>

Works perfectly thanks!

---

<div class="post-metadata">

**Author:** ![Rama](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rama/32/882413_2.png) [@Rama](https://forums.unrealengine.com/u/Rama)\
**Post date:** [July 9, 2014, 10:38pm UTC](https://forums.unrealengine.com/t/tarray-of-ustruct-of-dynamic-size-as-an-editable-uproperty/287675/5 "2014-07-09T22:38:37Z")

</div>

#The Correct Code

The final correct code should actually look like this

```
USTRUCT()
struct FSomeStruct()
{
    UPROPERTY(EditAnywhere,BlueprintReadWrite,Category("thingToEdit"))
    float thingToEdit;

    FSomeStruct()
   {
       thingToEdit = 0;
   }

}
 
UCLASS()
class ASomeClass()
{
   UPROPERTY(EditAnywhere,BlueprintReadWrite,Category("YourCategory"))
   TArray<FSomeStruct> Structs;
}

```

I posted this mainly for future viewers

---

<div class="post-metadata">

**Author:** ![Co](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Co](https://forums.unrealengine.com/u/Co)\
**Post date:** [January 21, 2015, 12:55pm UTC](https://forums.unrealengine.com/t/tarray-of-ustruct-of-dynamic-size-as-an-editable-uproperty/287675/6 "2015-01-21T12:55:23Z")

</div>

's code but UE 4.6+ compliant (his version was not compiling)

```
USTRUCT()
struct FSomeStruct
{
    GENERATED_USTRUCT_BODY()

    UPROPERTY(EditAnywhere,BlueprintReadWrite,Category ="YourCategory")
    float thingToEdit;

    FSomeStruct()
    {
        thingToEdit = 0;
    }
};

UCLASS()
class ASomeClass
{
    GENERATED_BODY()

    UPROPERTY(EditAnywhere,BlueprintReadWrite,Category = "YourCategory")
    TArray<FSomeStruct> Structs;
}

```
