Hello everyone! And thanks for checking my question topic.
I have created a custom editor graph, that fills an array of UObjects inside an asset. Let’s call asset BarDay and an array inside of it would be array of BarEvents. Basically it’s a graph, holding a bunch of Nodes each of which represents an event. Everything works inside editor, I can open asset at runtime then access object of **UBarDay **class and get any **UBarEvent **from TArray.
After I packaged project, I plugged debugger in and figured that every element in TArray is nullptr. The number of elements is correct though.
From here I assumed, since TArray initially holds a number of references, those refs are most likely created at asset construction and it is possible, that each time a start engine it runs construction for assets and since all nodes are in the asset it runs editor only functions and that creates all the UBarEvents thus filling the Array. And on packaged build the array of pointers is serialized, but those pointers are just wrong since no real objects exist. That is just an assumption though.
I’ve tried overriding serialization methods for UBarDay class and UBarEvent class, added various specifiers to UPROPERTY and UCLASS, but nothing helped.
Long story short: I need to understand how to save and correctly package TArray of UObjects inside an asset.
P.S. There is workaround to this, like creating array of structs with data and reconstruct all UBarEvents at runtime, but there’s a huge drawback for me, since all of Events are different child classes of UBarEvent so I would need like 12 different TArrays of 12 specially created structs, not to mention that I have to maintain their order wich would be extra job having all those different arrays. Also I might need more derived classes in future, so I’d prefer not to use this workaround.