I have some code in a ScriptedImporter that is essentially a loop, where each iteration of the loop:
- Makes a JSON call to a database to get a resource filepath
- Copies the resource from that filepath to the Unity project
- Calls AssetDataabase.ImportAsset(resource, ImportAssetOptions.ForceSynchronousImport)
However it doesn’t appear to be running synchronously as I desire. I can tell because all of the individual database queries finish BEFORE Unity starts importing the assets. At least visually that is what I am seeing. I need to write up some debug code to be certain.
Anyone else seeing this? Unity 2017.2
I’m 90% certain this is the case now. On top of visually seeing all the DB requests finish long before the first Import Progress Bar from Unity shows up, I added a call to load the asset immediately after the import asset call, and that load asset call fails every time which tells me it hasn’t yet loaded.
It actually seems like the import doesn’t even start when I make the call, but rather starts when my OnImportAsset() method terminates, which is of course too late for me to use the data.
After some more testing it appears that this method and the Synchronous flag does work OUTSIDE of the ScriptedImporter, so this is a (bug?) issue with using it inside of a ScriptedImporter 
Seeing exactly the same issue post 4 years. Omg what the * is Unity doing all these years.
1 Like