Using Resources folder causes long "Re-Imporing " Delays

On our game we generate random maps and at run time. We load chunks of level using LoadResources, instantiate those chunks, then UnloadUnusedAssets before generating the next level. The chunks are simply prefabs, but the prefab nesting depth is perhaps 3 or 4 layers deep before you get to basic meshes and sprites.

In the editor we have a growing problem in that, when we save a prefab that is referenced by many other prefabs, we get an “Importing” dialog.. for up to 60s or more.

As a work around we can delete the contents of the Resources folder, make changes to the content, then restore the resources folder and only suffer the Importing dialog once. (rather than every time you save an asset.)

Is this expected behavior or something we have set up incorrectly?

Why would changing the material on single asset in a prefab force an Import of hundreds of assets?

We don’t have a need for Asset Bundles or the Addressable package because none of our content is downloadable and we are not concerned about patch sizes. We would like to stick with using the Resources folder.

NOTE: This post was updated to clarify some points.

Resources is effectively a hard coded Asset Bundle. I imagine if it’s being loaded up with assets, any change will invalidate the cached bundle and cause Unity to rebuild it. The more assets, the longer it takes.

Probably worth exploring the use of Addressables over Resources.

I thought Addressables are also built on an Asset Bundle. If my level chunks are just in the Default Local Group, wont I have the same issue?

With Addressables you build the bundles when you need to (either manually, or automatically before a build). So there’s no rebuilding of groups during general editor usage.

yes, I would like that for my resource folder too please!

Under the hood, Resources is probably always using the asset bundle to load assets even in the editor, meaning it always has to be rebuilt.

Addressables, by default, uses Asset Database to load assets in the editor, allowing you to design your groups without needing the bundles to be rebuilt. It can also be configured to use your existing built groups to simulate loading times, etc.

You could submit a bug report, but you’ll just be told that Resources is no longer being updated and to use Addressables instead.

I changed the game to load the chunks as addressables and get the same issue. Long imports whenever you save an asset.

Then it’s probably unrelated to Resources or addressables/asset bundles, and something else is causing those assets to need to be reimported every time.

Hopefully somebody who knows will chime in.

One interesting observation. Saving a change will trigger the import, but reverting the change back again does not!

Do you have anything that is regularly modifying all these assets? They should only be reimported if they’ve been changed without the editor having been informed.

OnValidate being one such possibility, or other editor code.

What’s your editor version? I’m on 6.3.14f1 and this is giving me rather unexpected “Importing ..” progress bars as well, though I have none of my own assets in Resources.

Still, wondering if perhaps there’s an underlying issue here? I didn’t have these importing issues in 6.0 but of course those were different projects.

Specifically what kind of asset, and how is it being saved?

If the saving happens via your own scripts, scrutinize those or post them here. There’s a lot of crud written against the (crud) AssetDatabase API and some things will scale exponentially. You may have added 10% more items and suddenly the saving pops up the Import progress, then add 10 more and it’s minutes.

Common problems include saving many assets without Start/StopAssetEditing, and using SaveAssets (everything!) and Refresh (not normally required!) indiscriminately because that’s what cargo cult tells us to do.

Note that Refresh() calls UnloadUnusedAssets internally, and that can be a neckbreaker specifically for your Resources-based workflow.

Also scrutinize any other scripts that hook into events for asset import, domain/scene/etc load and unload, and so forth. It’s easy to trigger an event chain reaction that runs through several loops, bloating the time it takes to do something that seems trivial.

We are on 6.3.11. Saving is not happening in our own scripts.

We do have one asset import script. I will have a look at it. Thanks for the suggestion.

Yeah sorry, I should say it is saving prefabs that triggers the reimport, and I assume it is doing some work for each other prefab that includes that prefab.

So for example, if I save the door prefab, which is used everywhere, there is a long delay. But when I save some prefab that is only used occasionally, the import delay will be less.

There is some bug somewhere given that making the change triggers the import, but undoing the change does not!