By default, Unity imports assets one after another sequentially on the main Editor process. However, Unity also supports parallel importing for some types of asset. Parallel importing uses multiple processes to import assets simultaneously, which is faster than the default sequential method of importing.
To enable parallel importing, go to Edit > Project Settings > Editor, then under the Asset Pipeline section, enable the Parallel Import checkbox.
Unity’s Parallel Import feature supports only certain types of asset. It applies only when the Editor is performing its standard asset database refresh, which occurs when it detects new or modified assets in the Project folder and automatically imports them.
The specific types of asset which Unity can import in parallel are:
Other types of asset are always imported sequentially during an asset database refresh.
Some Asset Database API methods also respect this setting, if you use them to import, refresh, or create Texture or Model assets. These are:
Because parallel imports operate in a separate worker instance of the Unity editor any AssetPostprocessors handling Texture or Model imports will also take effect in that instance rather than the main Editor process.
Any side effects of these processors can cause unexpected problems. For example, if you modify a static variable on a C# class during the execution of a post process, that modification will not affect the code running in the Editor.
Any code that you write for post processors should always be self-contained, deterministic, and shouldn’t change the context it’s running in. For example, it shouldn’t change the Editor settings or create new assets on disk.
Following these rules helps your processor code avoid parallel threading issues and ensures that the results are always consistent.
In the Asset Pipeline settings, there are three settings that allow you to control the behaviour of the import worker processes. These settings are project-specific.
Property name | Description |
---|---|
Desired Import Worker Count | The number of import worker processes that the import pipeline considers the optimal number to run in parallel. |
Standby Import Worker Count | The minimum number of worker processes to keep, even if they’re idle. If there are more worker processes than this, Unity shuts down import workers that have been idle for some time, to free up system resources. This property allows you to manage how Unity balances system resources when some processes are idle, compared with the time it takes to start up new import worker processes. You might see an improvement in import performance by increasing this value if you are frequently iterating on model, animation or texture work, and are therefore frequently importing batches of models or image files. |
Idle Import Worker Shutdown Delay | The amount of time in seconds to wait before shutting down an idle worker. |
You can also control the default values that Unity sets the Desired Import Worker Count for new projects. To do this, go to Preferences > Asset Pipeline > Import Worker Count %.
When you create a new project, Unity uses the Import Worker Count % value to assign your project’s Desired Import Worker Count value to the percentage of the number of logical cores available on your system.
For example, if your system has 16 logical cores and this preference is set to 25%, the Desired Import Worker Count for new projects is 4. If you set this value too high, your import worker processes need to compete over other processes and system resources such as reading and writing files. The default value of 25% is suitable for most situations.