Editor hanging when saving created assets in Editor script?

Posted in Unity answers, no luck, so I’m hoping maybe someone will know here:

I am saving about 2500 meshes at the end of my editor script that were created in the editor script. It works fine usually, but for this batch of meshes, which is still similar to the others, it doesn’t seem to want to let go when saving the assets.

If I look in my documents they are all saved, and if I exit and reopen they are there, but it still is getting hung up in the editor which prevents me from saving the actual scene after that. Which is a problem in this case because there are also things I’ve done in the scene that need to be saved. Here is how I save the asset meshes:

AssetDatabase.SaveAssets ();

Im going to try to just skip right to saving scene and see what happens. I have a feeling that will still save assets as well and still freeze. Will report back…

yep. its hanging when just trying to save the scene after too. makes no sense to me as the other sets of meshes work great.

How are the new assets different? What type of assets are they? You might try putting a debug call in the loop, it might show where it is hanging. It also may slow the process down just enough to not get caught up.

I did something similar a while ago, and ended up building in a batch/chunk type feature. So instead of building everything at once, it would only process a few hundred, then keep track of where it left off. So I would have to hit the process button after each batch to do the next set. Added a few more button clicks, but it prevented hangs, and if something went wrong it was easier to find out where.

I tried doing debug but it never gets shown because of the hang up. I added a vertex counter to make sure it wasnt making too big of meshes, and it isnt. And I can’t use yields since its an editor script. Trying to think of how to give it a break. Maybe I should save multiple times per 500 meshes or something.

Added a more certain way of ending the script if a mesh is over limit. And added saving per 500 meshes. Annnnnd it hangs on the first save. I don’t get it scratches head

I wonder if there is some metadata from previous attempts of those meshes or something. Makes no sense, it works on other variations of basically the same thing. I’m trying saving per 100.

Okay so with just 100, I get an actual crash not a hang, bug reporter pops up.

error log says

“Unity.exe caused an Access Violation (0xc0000005)
in module Unity.exe at 0033:414fe0a5.”

and

“Read from location 0589affc caused an access violation.”