Skip to content

Import UnityPackages from a queue

Last updated

Queue UnityPackage import requests from your own editor extension and import them in order. All types are in the com.amari_noa.unitypackage_pipeline_core.editor namespace.

  1. Get the pipeline from AmariUnityPackageImportPipeline.Service. A single pipeline is created when the editor starts (and on every Domain Reload), and all callers share it.

    using com.amari_noa.unitypackage_pipeline_core.editor;
    var service = AmariUnityPackageImportPipeline.Service;
  2. Subscribe to the ImportRequestFinalized event to receive results. For what you receive, see Receive import results.

    service.ImportRequestFinalized += result =>
    {
    // Use result.ImportStatus, result.ImportedAssets, and so on
    };
  3. Create an AmariUnityPackageImportRequest and add it to the queue with Enqueue. The second argument (tags) is optional. To add several requests at once, use EnqueueMultiple.

    service.Enqueue(new AmariUnityPackageImportRequest(
    "C:/Downloads/Example.unitypackage",
    new[] { "example-tag" }));
  4. Call StartImport to start importing from the head of the queue. When a request completes, the pipeline moves on to the next one automatically.

    service.StartImport();

Tags in a request are added as Unity asset labels to the top level of the imported assets (such as Assets/<folder name>). Existing labels are kept.

  • Leading and trailing spaces are removed, and duplicate tags are merged.
  • Tags can contain letters, digits, _, -, ., and /, and can be up to 128 characters long. If a tag does not meet these rules, the request fails.
Property Description
InteractiveMode When true, shows Unity’s standard Import Unity Package window so the user can confirm. When false, imports without confirmation. The default is true
PreImportAnalysisMode Whether to check for changes before importing. Full (the default) skips the import when nothing has changed. Skip always imports
QuietMode While true, defers QueueChanged notifications while requests remain in the queue, then raises one notification when set back to false. Also suppresses some of this package’s info and warning logs
  • ClearQueue removes the pending requests. The request in progress stays and continues.
  • ResetPipelineAndClearQueue ends the request in progress as cancelled (with the reason PipelineReset) and empties the queue.

The members of IAmariUnityPackageImportPipelineService are as follows.

Member Description
Enqueue / EnqueueMultiple Adds import requests to the queue
StartImport Starts importing from the head of the queue. Does nothing if a request is already in progress
ClearQueue Removes pending requests (the request in progress stays)
ResetPipelineAndClearQueue Ends the request in progress as cancelled and empties the queue
IsImporting Whether a request is in progress
RemainingCount The number of requests left in the queue (including the one in progress)
CurrentTags The normalized tags of the request in progress
GetQueueSnapshot Gets a copy of the queue
InteractiveMode / PreImportAnalysisMode / QuietMode Behavior settings (see above)
ImportRequestFinalized Raised when a request ends as completed, failed, or cancelled
QueueChanged Raised when the queue or the processing state changes
RegisterHook / UnregisterHook Registers or unregisters a hook