Myself and my colleagues use ScriptedImporters alot nowadays as it allows us to do certain data processing up front instead of during the build process or worse, at runtime. One thing that has come up a number of times now though is that we have no way to get a hold of the currently imported asset prior to a Re-import.
I’ve tried OnPreprocessAsset()
in an AssetPostprocessor
but the old asset has already been destroyed. We have a number of use cases for this:
- If the data we’ve currently got imported is already in the right format according to the serialized import parameters, we want to prevent reimport (we’ve had this recently with certain custom texture compression importers, where we get a reimport just because we change the AssetBundle or another unimportant serialized field in the importer).
- I have an importer which creates a serialized object. That serialized object allocates a NativeArray for some of its serialized data for performance (in editor and runtime) in OnEnable and it disposes of it in OnDisable. We do not get an OnDisable call on our ScriptableObject on a reimport, so we leak memory in the editor.
We’d like some way to get a hold of our previously imported object right before a reimport occurs so we can react accordingly.