This fixes two closely related bugs. The root of the problem of both bugs is that you are serializing only those properties that are different from class default object (CDO).
The first issue with this approach is that the user can set a different default value for the component variable inside an actor (e.g., true while CDO would have false). Then modify this value in an actor instance inside a prefab such that it is equal to the component CDO (i.e., false). In such a case, the value will not be serialized since HasDefaultValue method will return true. However, when spawning the prefab, the (wrong) default value from the actor (i.e., true) will be used. Therefore you need to use a CDO object of the component's owner to retrieve the correct default values. This approach, however, works only for native C++ classes as the blueprint classes do not have a correct CDO available. Therefore, I spawn a copy of the actor and delete it later in such cases. Maybe you (or someone else) can point me towards a better solution for blueprint actors as I am not familiar with how exactly CDOs works in this case.
Now on the second problem. When you change a property of an actor inside a prefab from anything back to the default value, this change is not propagated to existing prefabs. The problem is that you are reusing existing actors in the spawned prefabs. Since the value is not stored (being the default one), this spawned actor will not be updated correctly. The solution I come up with is to change the actor PrefabItemID inside the ActorData array in case the actor was modified when saving the prefab. This forces the plugin not to reuse the existing actor if it was modified, and it spawns a new one instead.
This fixes two closely related bugs. The root of the problem of both bugs is that you are serializing only those properties that are different from class default object (CDO).
The first issue with this approach is that the user can set a different default value for the component variable inside an actor (e.g., true while CDO would have false). Then modify this value in an actor instance inside a prefab such that it is equal to the component CDO (i.e., false). In such a case, the value will not be serialized since HasDefaultValue method will return true. However, when spawning the prefab, the (wrong) default value from the actor (i.e., true) will be used. Therefore you need to use a CDO object of the component's owner to retrieve the correct default values. This approach, however, works only for native C++ classes as the blueprint classes do not have a correct CDO available. Therefore, I spawn a copy of the actor and delete it later in such cases. Maybe you (or someone else) can point me towards a better solution for blueprint actors as I am not familiar with how exactly CDOs works in this case.
Now on the second problem. When you change a property of an actor inside a prefab from anything back to the default value, this change is not propagated to existing prefabs. The problem is that you are reusing existing actors in the spawned prefabs. Since the value is not stored (being the default one), this spawned actor will not be updated correctly. The solution I come up with is to change the actor PrefabItemID inside the ActorData array in case the actor was modified when saving the prefab. This forces the plugin not to reuse the existing actor if it was modified, and it spawns a new one instead.