My dynamic arrays still empty

Hello,

Yesterday I tried to use dynamic arrays in my project and make them editable in BP, then I added a few elements in it. My problem is that the array length still equal to 0.

I even used the example code from here: A new, community-hosted Unreal Engine Wiki - Announcements - Unreal Engine Forums but I still can’t get it work.

The example USTRUCT I used:

USTRUCT()
struct FFlowerStruct
{
	GENERATED_USTRUCT_BODY()
 
	UPROPERTY()
	int32 NumPetals;
 
	UPROPERTY()
	FLinearColor Color;
 
	UPROPERTY()
	FVector Scale3D;
 
	void SetFlowerColor(const FLinearColor& NewColor)
	{
		Color = NewColor;
	}
 
	FFlowerStruct()
	{
		NumPetals 	= 5;
		Scale3D 		= FVector(1,1,1);
		Color 			= FLinearColor(1,0,0,1);
	}
};

And the UPROPERTY:

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Flowers")
TArray<FFlowerStruct> FlowerStruct;

The array in my BP:

http://puu.sh/kYgfH/a51ae4d0dc.png

And then when I try to get the length either in BeginPlay or Constructor or Tick the array always return 0.

I hope you’ll can help me :slight_smile:

Thanks

Are you trying to add an exposed TArray of your struct?

Oops my code example was wrong, my bad, I wanted to write:

TArray<FFlowerStruct> FlowerStruct;

instead of

TArray<FName> FlowerNames;

I updated the first post.
But anyway I still can’t get the real amount of element in Array.

in console (in game or PIE) type in “displayall ClassName FlowerStruct” (in place of ClassName you put name of class where that array is) and see if array is truly not empty on runtime

Ok then what you are missing is

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Flowers")

In your struct fields apart from using USTRUCT(BlueprintType) in your struct define.

If you ask me this should not make edtor show that array is 0, USTRUCT() as well as UPROPERTY() is enouth for UE4 to see array and struct members in reflection system. But makes me wonder how he get length without BlueprintType

That’s true but I prefer getting the basic right first, might just a simple thing that went wrong ^^. I just tried to replicate it on my end and it works fine.

Thank you that was the problem ^^", it’s not really obvious to find when you begin in UE4 X)

Thanks a lot