Parallel asset creation

Hi,
I have a large terrain I created in the editor and I want to export it to a unity package.
My terrain is saved in a mesh but not an asset. So currently when I export I do a for loop that goes over each tile and creates an asset and prefab for it.
Is there a way for me to run it in parallel and not sequentially?
Thanks in advance!

No, you can’t parallelize that. But I imagine it’s slow because you call CreateAsset for each asset without using this to prevent Unity from automatically importing every new asset right away:

            try
            {
                AssetDatabase.DisallowAutoRefresh();
                AssetDatabase.StartAssetEditing();

                // perform your asset creation here
            }
            finally
            {
                AssetDatabase.StopAssetEditing();
                AssetDatabase.AllowAutoRefresh();
            }

Feel free to post your code so we can look at other inefficiencies.

1 Like