Import assets out of process
Import multiple assets at the same time out of the Unity Editor process.
阅读时间3 分钟最后更新于 21 天前
By default, Unity imports assets one after another sequentially in the main Unity Editor process. However, you can use the Parallel Import setting to import the assets of certain types out of the Editor process. The Parallel Import setting uses additional headless instances of the Editor, called import workers, to import assets in parallel, which is faster than the default sequential method of importing.
Supported importers
Only certain importers support out of process importing. The following importers run out of process by default:
Importer | Asset type |
|---|---|
| Image files. |
| Model files. |
| Audio files. |
| Video files. |
| Text asset files. |
| Prefab files. |
| |
| Font files. |
| Assets in Unity's native serialized format, such as |
| Visual effect graph files: |
Other types of asset are always imported sequentially during an Asset Database refresh.
To change which importers run out of process for a single Editor session, use the and command line arguments. For example:
-OutOfProcessImporters-exclude-OutOfProcessImportersArgument | Functionality |
|---|---|
| Unity imports video files in the Editor process. Every other importer in the preceding table still imports out of process. |
| Unity imports the assets that |
Some Asset Database API methods also respect this setting if you use them to import, refresh, or create assets that a supported importer handles. These are:
Enable out of process importing
To enable out of process importing:
- Go to Edit > > Editor.Project Settings
?
- Under the Asset Pipeline section, enable the Parallel Import setting.
Out of process importing only happens when the Editor performs a standard Asset Database refresh, which happens when it detects new or modified assets in the Project folder and automatically imports them.
Effects of out of process importing on AssetPostprocessor instances
Out of process importing operates in a separate worker process instead of the main Editor process. Any instances that handle imports for the supported importers take effect in the worker instance rather than in the main Editor process.
AssetPostprocessorBecause of this, any code you write for post processors must be self-contained, deterministic, and must not change the context it's running in. For example, don't use an to change the Editor settings or create new assets on disk. Following these rules ensures that import results are always consistent.
AssetPostprocessorControlling the import worker processes
You can use the Asset Pipeline Project settings to control the behavior of the import worker processes. These settings are project-specific.
You can also control the default values for the Desired Import Worker Count for new projects in the Settings window. To do this, go to Settings > 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 the preference is set to 25%, the Desired Import Worker Count for new projects is 4. If you set this value too high, the import worker processes need to compete over other processes and system resources such as reading and writing files. The default value is 25% which suits most situations.