EditFixedSize - Can't update size in created BP

Hi,

when settings EditFixedSize, we just want the user to not edit the array size that we planned to set in C++.

But, as of today, if I set an array of 2 elements with EditFixedSize.
Create a BP on it
Change the C++ to add a 3rd element
Open the BP => 2 element and you can’t get the third one.

Are you able to repro this?

Thanks,

Hey -

Can you elaborate on what’s happening? It sounds like the size of the array is not updating in the blueprint when it is updated in the code, is that correct? If you create a new blueprint after updating the code does it have 2 or 3 elements? How are you using EditFizedSize? Can you post a code snippet to show how you have your class setup?

Cheers

Hi,

You are right, the array size is not updated in the BP when the C++ is updated.

If I create a new BP after the C++ change it reflects the correct size.

here is a snippet:

UPROPERTY(Instanced, EditAnywhere, EditFixedSize,BlueprintReadWrite, Category = "Test") 
	TArray< class UMyClass* > MyArray;

In the C++ Constructor, you can use to add default element:
MyArray.Add(MyClassInstance);

Once you BP is setup, you just add another line of:
MyArray.Add(MyClassInstance);

I hope this is enough for you to repro the issue.

Hey -

I’m not seeing the same behavior. When I copied your code into a class I had to add “” after TArray to get it to compile, but when I created a blueprint of my class the blueprint and instance of the blueprint in the viewport would update each time I added a new element in the constructor.

Hi,

I updated my comment so everything appears as I wrote it. the output that you were seing was not exactly what I wrote.

In all case, could you please share with me the property that you set in C++ so I can understand the differences if there are some and test it on my side?

Does the Array that you used had one element before the BP was created or was it empty?

thanks,

I created 2 classes based on Actor (ActorArray and MyActor). In MyActor I created the following TArry:

UPROPERTY(Instanced, EditAnywhere, EditFixedSize, BlueprintReadWrite, Category = "Test")
		TArray< class AActorArray* > MyArray;

and the following AActorArray pointer:

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Things")
		AActorArray* what;

In the constructor for MyActor I then added an element to the array:

MyArray.Add(what);

After compiling the code I created a blueprint based on MyActor and added an instance to the viewport. At this point I could see the one element of the array in the details panel. Back in the constructor of MyActor I added a second element to the array and compiled again which triggered a hot reload in the editor. After the hot reload the instance of the BP in the viewport showed 2 elements.

Hey -

I’ve not heard back on if the sample code I provided was able to help you with setting up your array. I will be marking this post as resolved for tracking purposes however if you’re still having problems seeing new elements of an array after compile please feel free to comment on this post and we will investigate further.

Cheers

Sorry for the late answer on this.

 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Things")
         AActorArray* what;

I’m not sure to follow why you set UPROPERTY. I don’t need to hold the reference to my InstancedClass as they are in the Array.

The way I’m doing this:
In the contructor:

UMyClass* classInst= ObjectInitializer.CreateDefaultSubobject<UMyClass>(this,TEXT("MyObject"));
MyArray.Add(classInst);
classInst= ObjectInitializer.CreateDefaultSubobject<UMyClass>(this,TEXT("MyObject2"));
MyArray.Add(classInst);

I hope this help to repro the bug.
More, my element in my Array are not Actor but Object, this is something to look if this is not link to it.

Thanks,

Hey -

Using an object instead of an actor I did see some inconsistency with the size of the array updating after a hot reload. I have bugged this behavior (UE-14992) for further investigation. In the cases where the array did not update I found that creating a new instance of the blueprint after the hot reload would show the correct number of elements. setting the UObject* as a UPROPERTY() I also found reduced the frequency of the inconsistency occurring.

ok great that you have been able to reproduce it.
If I remember properly, I think the issue is also when reloading the editor and not just hot reload

Hi,

any update on this?

thanks,

Hey -

I tested adding array elements in 4.9.2 and my blueprint instance updated with each addition. Let me know if you’re still seeing this in the latest engine version and what you’re doing in code/editor.

Good News. thanks for the update. I will reuse this in my code as it is fixed.