In a USTRUCT, there is a UObject based UPROPERTY that references a specific asset.
Upon a custom reimport function, that asset is deleted from the project and a possibly equivalent asset is created elsewhere in the content browser. That struct now has to be notified that due to its reference being nulled through the asset deletion, it should try and search for the new, equivalent asset in the content browser, restoring the reference based on criteria that aren’t relevant for the question.
Since USTRUCTs have no common base class, I have very limited access to context from within the struct.
I have tried registering all created instances of the USTRUCT so that I can manually access them and call the code to restore the references, but when I add the structs to an array in the constructor, the array will also contain trash values, possibly due to Unreal Engine calling the constructor for various reasons outside of actual object creation. I had 71 entries in the array with trash data when there should have been 5 entries at most, so caching all existing instances of this struct doesn’t seem to be a proper solution either, via the constructor at least.
Registering to an asset registry module event (OnAssetRemoved) in the constructor is therefore not a good option either, since the registering happens too often and is not a clean approach.
Can I somehow get all existing instances of the struct without caching them? Can I cache them properly somehow?
What can I do to access all instances of the struct that exist to update their internal references? Is there a way to properly get informed about the external nulling of an object reference? A struct customization only notifies me of when whe user manually changes the reference in the editor, not when for example a force delete nulls it from outside.