The rules for delta serialization in UE4 are complicated, and the editor tries to hide them from you, which works 90% of the time but can lead to confusion and data loss in other situations. In the repro above, there is a parent blueprint with a single variable struct, and an array of the same struct (FEngineTestNativeSubStruct). The child blueprint modifies a single variable inside both the single struct and the first array struct. But when the child blueprint is saved, it only saves out the modified variable in the single struct, but saves the entire array including values that are the same as the parent. This means the single struct still mostly inherits changes from the parent, but the array is completely disconnected from any changes the parent would get. This causes the behavior seen in step 6, and is a very old engine decision dating back at least 10 years.
To compensate for this, when making changes to arrays inside the parent the editor tries to modify any child blueprints (and actor instances) it knows about, but this only works if they are open. It does not tell the user it is doing this, but does mark the child bps and levels as dirty. In the UI the behavior looks identical between arrays and single structs, but because of the delta save behavior this is a lie. This leads to very confusing behavior for end users when they modify arrays inside parent blueprints, as changes appear to work most of the time, but will randomly fail. Maps and static arrays work like single structs, this is only an issue with TArray properties.
There are several possible fixes, one is to change it so TArrays do delta serialization like everything else in the engine, this would be the cleanest fix but could theoretically cause problems the opposite direction. Another option is to try and load the child BPs/instances, but this would be very expensive. A third option is to add some sort of notification or indication this is happening, such as a ! tooltip on array properties that are disconnected from their parents.
There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-96195 in the post.
19 |
Component | UE - Foundation - Core |
---|---|
Affects Versions | 4.26 |
Created | Jul 30, 2020 |
---|---|
Updated | Oct 9, 2024 |