Made a C++ class with an array of TSubclassOf variable
Compile
Run engine
Create blueprint base of the class
Add one item to the array, set the item to another blueprint
Close editor
Add EditFixedSize to array property and do AddZeroed(4) to constructor
Compile
Run engine
Blueprint only has the array of size 1, and can’t add new items either.
If new blueprint is created, then the default 4 items appear (all null).
So, is there a way for existing blueprint to reflect changes made in C++ ? We have made many blueprints already, remaking them is very time consuming, I’m guessing we have to find new ways to do what we’re trying to do.
The reason it doesn’t work the way you want is that your new constructor calls are not honoured by the way UE4 loads previously serialised objects. In your case, with the property being an array, it’s rather awkward to fix without doing them all manually.
Here’s an approach that may work.
You need to add code to call Array.SetNumZeroed(4) in a place where it will be executed after an object has been loaded. Try putting it in an override of PostInitProperties, though from memory this may be too early in the loading process. If that gets overwritten by the saved values, PostLoad might be the place. It will need to be called for the blueprint CDO, which is something I’m not sure about, but give those two places a try.
The idea is that after loading one of your existing blueprints with a single length array, it will pad the array out to length 4. So then you’d run the engine, check the blueprint has 4 array entries with the already configured one at index 0, then resave it. I don’t know if a single SaveAll would suffice or if you’d have to open and save every blueprint individually. Finally, remove the method override above, and from there you should be set.