AssetImporter
public abstract class AssetImporter : ActionProgressCoordinates package download, extraction, indexing, persistence, media analysis, and import-state transitions.
Methods
Section titled “Methods”
CanDownload(AssetInfo, bool)
Section titled “CanDownload(AssetInfo, bool)”protected static bool CanDownload(AssetInfo info, bool applyAutomaticLimit = true)Reports whether the package has a supported remote source and is not already being downloaded.
Parameters
| Name | Type |
|---|---|
info | AssetInventory.AssetInfo |
applyAutomaticLimit | System.Boolean |
Returns
System.Boolean
DownloadAsset(AssetInfo)
Section titled “DownloadAsset(AssetInfo)”protected IEnumerator DownloadAsset(AssetInfo info)Starts or joins download of the selected package and returns when a usable archive is available.
Parameters
| Name | Type |
|---|---|
info | AssetInventory.AssetInfo |
Returns
System.Collections.IEnumerator
RemoveDownload(Asset)
Section titled “RemoveDownload(Asset)”protected static IEnumerator RemoveDownload(Asset asset)Removes a successfully processed cached archive without deleting its catalog record.
Parameters
| Name | Type |
|---|---|
asset | AssetInventory.Asset |
Returns
System.Collections.IEnumerator
ApplyPackageTags(FolderSpec, Asset, bool)
Section titled “ApplyPackageTags(FolderSpec, Asset, bool)”protected static bool ApplyPackageTags(FolderSpec spec, Asset asset, bool fromAssetStore = false)Applies configured source-folder tags to an indexed package, optionally replacing existing automatic assignments.
Parameters
| Name | Type |
|---|---|
spec | AssetInventory.FolderSpec |
asset | AssetInventory.Asset |
fromAssetStore | System.Boolean |
Returns
System.Boolean
HasNoIndex(int)
Section titled “HasNoIndex(int)”protected static bool HasNoIndex(int assetId)Reports whether the package is configured to remain in the catalog without indexing its contents.
Parameters
| Name | Type |
|---|---|
assetId | System.Int32 |
Returns
System.Boolean
HasNoIndex(Asset)
Section titled “HasNoIndex(Asset)”protected static bool HasNoIndex(Asset asset)Reports whether the package is configured to remain in the catalog without indexing its contents.
Parameters
| Name | Type |
|---|---|
asset | AssetInventory.Asset |
Returns
System.Boolean
RemoveWorkFolder(Asset, string)
Section titled “RemoveWorkFolder(Asset, string)”protected static void RemoveWorkFolder(Asset asset, string tempPath)Removes the package’s temporary extraction directory after verifying it belongs to the importer workspace.
Parameters
| Name | Type |
|---|---|
asset | AssetInventory.Asset |
tempPath | System.String |
MarkDone(Asset)
Section titled “MarkDone(Asset)”protected static void MarkDone(Asset asset)Marks package indexing complete and persists the final state.
Parameters
| Name | Type |
|---|---|
asset | AssetInventory.Asset |
MarkInProcess(Asset)
Section titled “MarkInProcess(Asset)”protected static void MarkInProcess(Asset asset)Marks package indexing active so concurrent operations can avoid processing it twice.
Parameters
| Name | Type |
|---|---|
asset | AssetInventory.Asset |
Fetch(Asset)
Section titled “Fetch(Asset)”protected static Asset Fetch(Asset asset)Loads the latest persisted form of the supplied package or file record from the active database.
Parameters
| Name | Type |
|---|---|
asset | AssetInventory.Asset |
Returns
AssetInventory.Asset
Exists(AssetFile)
Section titled “Exists(AssetFile)”protected static bool Exists(AssetFile file)Reports whether an equivalent indexed file already exists in the active catalog.
Parameters
| Name | Type |
|---|---|
file | AssetInventory.AssetFile |
Returns
System.Boolean
Fetch(AssetFile)
Section titled “Fetch(AssetFile)”protected static AssetFile Fetch(AssetFile file)Loads the latest persisted form of the supplied package or file record from the active database.
Parameters
| Name | Type |
|---|---|
file | AssetInventory.AssetFile |
Returns
AssetInventory.AssetFile
Fetch(AssetFile, IEnumerable)
Section titled “Fetch(AssetFile, IEnumerable)”protected static AssetFile Fetch(AssetFile file, IEnumerable<AssetFile> existing)Loads the latest persisted form of the supplied package or file record from the active database.
Parameters
| Name | Type |
|---|---|
file | AssetInventory.AssetFile |
existing | System.Collections.Generic.IEnumerable{AssetInventory.AssetFile} |
Returns
AssetInventory.AssetFile
Fetch(AssetFile, Dictionary<string, List>, Dictionary<(string, int), AssetFile>)
Section titled “Fetch(AssetFile, Dictionary<string, List>, Dictionary<(string, int), AssetFile>)”protected static AssetFile Fetch(AssetFile file, Dictionary<string, List<AssetFile>> existingByGuid, Dictionary<(string, int), AssetFile> existingByPathAndAssetId)Loads the latest persisted form of the supplied package or file record from the active database.
Parameters
| Name | Type |
|---|---|
file | AssetInventory.AssetFile |
existingByGuid | System.Collections.Generic.Dictionary{System.String,System.Collections.Generic.List{AssetInventory.AssetFile}} |
existingByPathAndAssetId | System.Collections.Generic.Dictionary{System.ValueTuple{System.String,System.Int32},AssetInventory.AssetFile} |
Returns
AssetInventory.AssetFile
ToGuidDict(IEnumerable)
Section titled “ToGuidDict(IEnumerable)”protected static Dictionary<string, List<AssetFile>> ToGuidDict(IEnumerable<AssetFile> files)Groups indexed files by GUID so dependency resolution can retain every file sharing the same identifier.
Parameters
| Name | Type |
|---|---|
files | System.Collections.Generic.IEnumerable{AssetInventory.AssetFile} |
Returns
System.Collections.Generic.Dictionary{System.String,System.Collections.Generic.List{AssetInventory.AssetFile}}
ToIdDict(IEnumerable)
Section titled “ToIdDict(IEnumerable)”public static Dictionary<int, AssetFile> ToIdDict(IEnumerable<AssetFile> files)Indexes files by their catalog identity for constant-time lookup during import processing.
Parameters
| Name | Type |
|---|---|
files | System.Collections.Generic.IEnumerable{AssetInventory.AssetFile} |
Returns
System.Collections.Generic.Dictionary{System.Int32,AssetInventory.AssetFile}
ToPathIdDict(IEnumerable)
Section titled “ToPathIdDict(IEnumerable)”protected static Dictionary<(string Path, int AssetId), AssetFile> ToPathIdDict(IEnumerable<AssetFile> files)Indexes files by normalized path and owning package identity so equal paths in different packages remain distinct.
Parameters
| Name | Type |
|---|---|
files | System.Collections.Generic.IEnumerable{AssetInventory.AssetFile} |
Returns
System.Collections.Generic.Dictionary{System.ValueTuple{System.String,System.Int32},AssetInventory.AssetFile}
Persist(Asset)
Section titled “Persist(Asset)”public static void Persist(Asset asset)Inserts or updates the supplied package or file record and returns the persisted catalog identity.
Parameters
| Name | Type |
|---|---|
asset | AssetInventory.Asset |
ValidatePreviewFile(AssetFile, string, bool)
Section titled “ValidatePreviewFile(AssetFile, string, bool)”public static string ValidatePreviewFile(AssetFile file, string previewFolder, bool nullOnError = true)Validates a generated preview and updates preview state without accepting missing or placeholder output.
Parameters
| Name | Type |
|---|---|
file | AssetInventory.AssetFile |
previewFolder | System.String |
nullOnError | System.Boolean |
Returns
System.String
Persist(AssetFile)
Section titled “Persist(AssetFile)”protected static void Persist(AssetFile file)Inserts or updates the supplied package or file record and returns the persisted catalog identity.
Parameters
| Name | Type |
|---|---|
file | AssetInventory.AssetFile |
UpdateOrInsert(Asset)
Section titled “UpdateOrInsert(Asset)”protected static void UpdateOrInsert(Asset asset)Updates the matching package record when present, otherwise inserts it as a new catalog package.
Parameters
| Name | Type |
|---|---|
asset | AssetInventory.Asset |
ProcessMediaAttributes(string, AssetFile, Asset)
Section titled “ProcessMediaAttributes(string, AssetFile, Asset)”protected static Task ProcessMediaAttributes(string file, AssetFile info, Asset asset)Reads supported image dimensions and audio metadata into the indexed file record.
Parameters
| Name | Type | Description |
|---|---|---|
file | System.String | Path to the file available to the importer. |
info | AssetInventory.AssetFile | The indexed file record to update. |
asset | AssetInventory.Asset | The source package used to materialize audio when a header does not provide its duration. |
Returns
System.Threading.Tasks.Task
Remarks
Call from the editor thread because the audio backend can load the file through Unity.
GetDefaultImportSpec()
Section titled “GetDefaultImportSpec()”protected static FolderSpec GetDefaultImportSpec()Returns the default source-folder rules used for manually imported packages.
Returns
AssetInventory.FolderSpec
Constructors
Section titled “Constructors”
AssetImporter()
Section titled “AssetImporter()”protected AssetImporter()