#Question regarding AssetPostProcessor

1 messages · Page 1 of 1 (latest)

winter glade
#

Hi ! I am working on a tool for my colleagues to quickly search a specific ScriptableObject within a group of thousands of elements (big project). I made a cache to reduce the impact of fecthing all existing assets and loading them, and tried to push a little further to maintain my cache up to date when new assets are created or deleted. My first thought was to use AssetPostProcessor.OnPostProcessAllAssets, which "works" but came with an issue: saving the project (ctrl+s) is longer and can get stuck.

Most of the example I found on the internet were focus on models post processing, so I was wondering if using AssetPostProcessor was a good idea in the first place and/or if anyone had any tips to do it correctly. 😅

rugged depot
#

What are you doing inside of OnPostProcessAllAssets? Are you searching the entire project for your SO assets, or are you only looking at the importedAssets/etc. arrays?

winter glade
rugged depot
#

okay, so you aren't scanning the entire project for assets every time – that'd certainly cause a slowdown

#

You mentioned that it can "get stuck" – does it wind up in some kind of infinite asset importing loop?

winter glade
#

My first thought is that an inspector that access my cache is trying to do it while the save project/reimport occurs, resulting in such issue.

rugged depot
#

You should be able to attach a debugger and pause it to find out where, exactly, you're getting stuck

#

(as long as it's not in native code that you can't observe)

#

The function will run repeatedly if you're causing assets to be reimported. I'd have a look at what's being passed to it each time (especially when the editor gets stuck)

#

even if the editor is frozen, you can still watch the Editor.log file

winter glade
#

What can trigger a reimport aside from calls like CreateAsset or ReimportAll ?

rugged depot
#

If you're modifying an asset inside of OnPostProcessAllAssets, it'll be run again