文档

Unity Engine

Download Unity

Unity Engine

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

TextureImporter
Image files.
ModelImporter
, including
FBXImporter
and
Mesh3DSImporter
Model files.
AudioImporter
Audio files.
VideoClipImporter
Video files.
TextScriptImporter
Text asset files.
PrefabImporter
Prefab files.
ShaderImporter
,
ComputeShaderImporter
,
RayTracingShaderImporter
.shader
,
.compute
and
.raytrace
files.
TrueTypeFontImporter
Font files.
NativeFormatImporter
Assets in Unity's native serialized format, such as
.asset
,
.mat
and
.controller
files.
VisualEffectImporter
Visual effect graph files:
.vfx
,
.vfxoperator
and
.vfxblock
.
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
-OutOfProcessImporters
and
-exclude-OutOfProcessImporters
command line arguments. For example:

Argument

Functionality

-exclude-OutOfProcessImporters VideoClipImporter
Unity imports video files in the Editor process. Every other importer in the preceding table still imports out of process.
-OutOfProcessImporters MyImporter
Unity imports the assets that
MyImporter
handles out of process, in addition to every importer in the preceding table.
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:
  1. Go to Edit >
    Project Settings

    ?

    > Editor.
  2. 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
AssetPostprocessor
instances that handle imports for the supported importers take effect in the worker instance rather than in the main Editor process.
Because 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
AssetPostprocessor
to change the Editor settings or create new assets on disk. Following these rules ensures that import results are always consistent.

Controlling 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.

Additional resources