Skip to content

Assets

ClassAssetInventoryAssetInventory.Editor
public static class Assets

Provides package-level catalog operations, including loading package records, extracting archives into the managed cache, and importing selected content into the Unity project.

Extract(Asset, AssetFile, bool, CancellationToken)

Section titled “Extract(Asset, AssetFile, bool, CancellationToken)”
public static Task<string> Extract(Asset asset, AssetFile assetFile = null, bool fileOnly = false, CancellationToken ct = default)

Extracts an asset from its archive to the materialized cache folder.

Parameters

NameType
assetAssetInventory.Asset
assetFileAssetInventory.AssetFile
fileOnlySystem.Boolean
ctSystem.Threading.CancellationToken

Returns

System.Threading.Tasks.Task{System.String}

public static bool IsMaterialized(Asset asset, AssetFile assetFile = null)

Reports whether the selected package or file currently exists in usable local storage.

Parameters

NameType
assetAssetInventory.Asset
assetFileAssetInventory.AssetFile

Returns

System.Boolean

EnsureMaterialized(AssetInfo, bool, CancellationToken)

Section titled “EnsureMaterialized(AssetInfo, bool, CancellationToken)”
public static Task<string> EnsureMaterialized(AssetInfo info, bool fileOnly = false, CancellationToken ct = default)

Ensures the selected asset and requested dependencies exist in local storage, returning the resolved path and honoring cancellation.

Parameters

NameType
infoAssetInventory.AssetInfo
fileOnlySystem.Boolean
ctSystem.Threading.CancellationToken

Returns

System.Threading.Tasks.Task{System.String}

EnsureMaterialized(Asset, AssetFile, bool, CancellationToken)

Section titled “EnsureMaterialized(Asset, AssetFile, bool, CancellationToken)”
public static Task<string> EnsureMaterialized(Asset asset, AssetFile assetFile = null, bool fileOnly = false, CancellationToken ct = default)

Ensures the selected asset and requested dependencies exist in local storage, returning the resolved path and honoring cancellation.

Parameters

NameType
assetAssetInventory.Asset
assetFileAssetInventory.AssetFile
fileOnlySystem.Boolean
ctSystem.Threading.CancellationToken

Returns

System.Threading.Tasks.Task{System.String}

public static List<AssetInfo> Load()

Loads the current indexed asset snapshot from the active database.

Returns

System.Collections.Generic.List{AssetInventory.AssetInfo}

CopyTo(AssetInfo, string, bool, int, bool, bool, bool, bool)

Section titled “CopyTo(AssetInfo, string, bool, int, bool, bool, bool, bool)”
public static Task<string> CopyTo(AssetInfo info, string folder, bool withDependencies = false, int scriptMode = 0, bool fromDragDrop = false, bool outOfProject = false, bool reimport = false, bool previewMode = false)

Copies an asset file to a destination folder, optionally including dependencies. Uses batched processing to minimize AssetDatabase.Refresh() calls and handles parallel execution safely via CopyCoordinator.

Parameters

NameType
infoAssetInventory.AssetInfo
folderSystem.String
withDependenciesSystem.Boolean
scriptModeSystem.Int32
fromDragDropSystem.Boolean
outOfProjectSystem.Boolean
reimportSystem.Boolean
previewModeSystem.Boolean

Returns

System.Threading.Tasks.Task{System.String}

public static Task<Dictionary<int, string>> CopyToBatch(List<AssetInfo> infos, string folder, bool withDependencies, bool previewMode)

Copies multiple asset files and their dependencies to a destination folder in a single batch. This dramatically reduces AssetDatabase.Refresh() calls by batching all files together. Used for bulk preview generation where many files from the same package need to be materialized.

Parameters

NameTypeDescription
infosSystem.Collections.Generic.List{AssetInventory.AssetInfo}List of assets to copy
folderSystem.StringTarget folder (typically the preview work folder)
withDependenciesSystem.BooleanWhether to include dependencies
previewModeSystem.BooleanWhether this is for preview generation (affects GUID reuse behavior)

Returns

System.Threading.Tasks.Task{System.Collections.Generic.Dictionary{System.Int32,System.String}}: Dictionary mapping AssetInfo.Id to the project-relative path of the copied file

public static bool RunURPConverter()

Runs the URP material converter if available (fire-and-forget).

Returns

System.Boolean: True if the Unity converter ran without error, false otherwise.

public static Task<bool> RunURPConverterAsync()

Runs the URP material converter and waits for it to complete.

Returns

System.Threading.Tasks.Task{System.Boolean}: True if the Unity converter ran successfully, false otherwise.

ConvertImportedMaterialsToPipeline(IEnumerable)

Section titled “ConvertImportedMaterialsToPipeline(IEnumerable)”
public static void ConvertImportedMaterialsToPipeline(IEnumerable<string> importedPaths)

Converts material assets at the given project-relative paths from BIRP to the current render pipeline.

Parameters

NameType
importedPathsSystem.Collections.Generic.IEnumerable{System.String}
public static void ConvertAllProjectMaterialsToPipeline()

Scans all materials in the project and converts any remaining BIRP materials to the current render pipeline.

GetExistingAssetPathForGuid(string, bool, bool)

Section titled “GetExistingAssetPathForGuid(string, bool, bool)”
public static string GetExistingAssetPathForGuid(string guid, bool previewMode, bool validateLoadable = false)

Checks if a file with the given GUID already exists in the project.

Parameters

NameTypeDescription
guidSystem.StringThe GUID to check
previewModeSystem.BooleanIf true, includes temp/preview folders; if false, excludes them
validateLoadableSystem.Boolean

Returns

System.String: The existing asset path if found and should be reused, null otherwise

public static void ForgetAssetFile(AssetFile info)

Removes an indexed file from the catalog without deleting its original source content.

Parameters

NameType
infoAssetInventory.AssetFile
public static void SetFilesHidden(List<int> fileIds, bool hidden)

Sets the hidden flag on the selected indexed file records without deleting their source or preview files.

Parameters

NameType
fileIdsSystem.Collections.Generic.List{System.Int32}
hiddenSystem.Boolean
public static List<string> GetHiddenPaths(int assetId)

Returns normalized paths currently marked hidden for the supplied package.

Parameters

NameType
assetIdSystem.Int32

Returns

System.Collections.Generic.List{System.String}

public static void RestoreHiddenPaths(int assetId, List<string> paths)

Restores hidden flags for matching paths after a package is reindexed and file identities have changed.

Parameters

NameType
assetIdSystem.Int32
pathsSystem.Collections.Generic.List{System.String}
public static void ApplyHidePatterns(int assetId)

Applies the package’s configured path patterns to hide matching indexed files.

Parameters

NameType
assetIdSystem.Int32
public static Asset ForgetPackage(AssetInfo info, bool removeExclusion = false, bool removeFiles = false)

Resets a package to “new” state for reindexing.

Parameters

NameType
infoAssetInventory.AssetInfo
removeExclusionSystem.Boolean
removeFilesSystem.Boolean

Returns

AssetInventory.Asset

public static void RemovePackage(AssetInfo info, bool deleteFiles)

Completely removes a package and all its data from the database.

Parameters

NameType
infoAssetInventory.AssetInfo
deleteFilesSystem.Boolean
public static int CountPurchasedAssets(IEnumerable<AssetInfo> assets)

Counts the number of purchased assets in the list.

Parameters

NameType
assetsSystem.Collections.Generic.IEnumerable{AssetInventory.AssetInfo}

Returns

System.Int32

public static Task PlayAudio(AssetInfo info, CancellationToken ct = default)

Plays an audio file from an asset, extracting it if necessary.

Parameters

NameTypeDescription
infoAssetInventory.AssetInfoThe asset info containing the audio file
ctSystem.Threading.CancellationTokenCancellation token for async operations

Returns

System.Threading.Tasks.Task

public static AssetInfo GetPackage(int packageId)

Loads the package record with the supplied catalog identity, or null when it no longer exists.

Parameters

NameType
packageIdSystem.Int32

Returns

AssetInventory.AssetInfo

DownloadPackageAsync(AssetInfo, CancellationToken)

Section titled “DownloadPackageAsync(AssetInfo, CancellationToken)”
public static Task<bool> DownloadPackageAsync(AssetInfo info, CancellationToken ct = default)

Downloads the selected remote package into Asset Inventory storage and returns whether a usable local package became available.

Parameters

NameType
infoAssetInventory.AssetInfo
ctSystem.Threading.CancellationToken

Returns

System.Threading.Tasks.Task{System.Boolean}

public static InventoryStats GetInventoryStats()

Calculates catalog totals, storage use, source distribution, and optional search-index health statistics.

Returns

AssetInventory.InventoryStats

public static List<AssetInfo> LoadPackagesForExport(string searchQuery = null, HashSet<int> packageIdFilter = null)

Loads package rows matching the supplied query fragment while excluding the specified package identities.

Parameters

NameType
searchQuerySystem.String
packageIdFilterSystem.Collections.Generic.HashSet{System.Int32}

Returns

System.Collections.Generic.List{AssetInventory.AssetInfo}