Skip to content

AssetImporter

ClassAssetInventoryAssetInventory.Editor
public abstract class AssetImporter : ActionProgress

Coordinates package download, extraction, indexing, persistence, media analysis, and import-state transitions.

protected static bool CanDownload(AssetInfo info)

Reports whether the package has a supported remote source and is not already being downloaded.

Parameters

Name Type
info AssetInventory.AssetInfo

Returns

System.Boolean

protected IEnumerator DownloadAsset(AssetInfo info)

Starts or joins download of the selected package and returns its local archive path when complete.

Parameters

Name Type
info AssetInventory.AssetInfo

Returns

System.Collections.IEnumerator

protected static IEnumerator RemoveDownload(Asset asset)

Removes cached download artifacts for the package without deleting its catalog record.

Parameters

Name Type
asset AssetInventory.Asset

Returns

System.Collections.IEnumerator

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

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

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

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
protected static void MarkDone(Asset asset)

Marks package indexing complete and persists the final state.

Parameters

Name Type
asset AssetInventory.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
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

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

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

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

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}}

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}

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}

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

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
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)

Extracts supported media dimensions, duration, and related attributes into the indexed file record.

Parameters

Name Type
file System.String
info AssetInventory.AssetFile
asset AssetInventory.Asset

Returns

System.Threading.Tasks.Task

protected static FolderSpec GetDefaultImportSpec()

Returns the default source-folder rules used for manually imported packages.

Returns

AssetInventory.FolderSpec

protected AssetImporter()