Skip to content

How a request is processed

Last updated

This page explains the order in which requests at the head of the queue are processed, and how Domain Reloads during processing are handled. Use it to check when hooks and result notifications occur.

  1. The pipeline validates and normalizes the tags. If a tag does not meet the rules, the request ends as failed.
  2. If PreImportAnalysisMode is Full, it checks for changes before importing. If nothing has changed, it treats the request as completed without running Unity’s import (see below).
  3. It calls the OnBeforePackageImport hook.
  4. It runs the import with AssetDatabase.ImportPackage and records the imported assets.
  5. After the import completes, it calls the OnPackageImportCompleted hook.
  6. If the request has tags, it adds them as asset labels to the top level of the imported assets.
  7. It reports the result to the OnImportRequestFinalized hook and then to the ImportRequestFinalized event, and removes the request from the queue.

When the request completes, processing returns to step 1 for the next request. For what happens to the queue on failure or cancellation, see Receive import results.

Each file in the UnityPackage is compared with the file at the same path in the project. If every file meets all of the following conditions, the package is treated as unchanged.

  • A file exists at the same path in the project (under Assets or Packages)
  • The SHA-256 hash of the file content matches
  • The GUID in the .meta file matches (if the GUID cannot be read, the SHA-256 hash of the whole .meta file is compared instead)

Even when the package is unchanged, hooks are called and tags are added as usual. If the UnityPackage cannot be read, a warning appears in the Console and the normal import runs.

Tags are added to the top level of the imported asset paths (Assets/<folder name>, or a file directly under Assets). Assets outside Assets (such as under Packages) are not labeled. Existing labels are kept, and only missing tags are added.

The queue and processing state are saved in Unity’s SessionState. After a Domain Reload, the request that was in progress restarts from the beginning. The saved state is discarded when the editor quits.

In 1.3 and later, Domain Reloads caused by script compilation are deferred while the queue is being processed and run once the queue is empty. The pipeline keeps track of processing even when you import several UnityPackages that contain scripts in a row.