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

Name Type
asset AssetInventory.Asset
assetFile AssetInventory.AssetFile
fileOnly System.Boolean
ct System.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

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

Name Type
info AssetInventory.AssetInfo
fileOnly System.Boolean
ct System.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

Name Type
asset AssetInventory.Asset
assetFile AssetInventory.AssetFile
fileOnly System.Boolean
ct System.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

Name Type
info AssetInventory.AssetInfo
folder System.String
withDependencies System.Boolean
scriptMode System.Int32
fromDragDrop System.Boolean
outOfProject System.Boolean
reimport System.Boolean
previewMode System.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

Name Type Description
infos System.Collections.Generic.List{AssetInventory.AssetInfo} List of assets to copy
folder System.String Target folder (typically the preview work folder)
withDependencies System.Boolean Whether to include dependencies
previewMode System.Boolean Whether 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

Name Type
importedPaths System.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

Name Type Description
guid System.String The GUID to check
previewMode System.Boolean If true, includes temp/preview folders; if false, excludes them
validateLoadable System.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

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

Name Type
fileIds System.Collections.Generic.List{System.Int32}
hidden System.Boolean
public static List<string> GetHiddenPaths(int assetId)

Returns normalized paths currently marked hidden for the supplied package.

Parameters

Name Type
assetId System.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

Name Type
assetId System.Int32
paths System.Collections.Generic.List{System.String}
public static void ApplyHidePatterns(int assetId)

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

Parameters

Name Type
assetId System.Int32
public static Asset ForgetPackage(AssetInfo info, bool removeExclusion = false, bool removeFiles = false)

Resets a package to “new” state for reindexing.

Parameters

Name Type
info AssetInventory.AssetInfo
removeExclusion System.Boolean
removeFiles System.Boolean

Returns

AssetInventory.Asset

public static void RemovePackage(AssetInfo info, bool deleteFiles)

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

Parameters

Name Type
info AssetInventory.AssetInfo
deleteFiles System.Boolean
public static int CountPurchasedAssets(IEnumerable<AssetInfo> assets)

Counts the number of purchased assets in the list.

Parameters

Name Type
assets System.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

Name Type Description
info AssetInventory.AssetInfo The asset info containing the audio file
ct System.Threading.CancellationToken Cancellation 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

Name Type
packageId System.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

Name Type
info AssetInventory.AssetInfo
ct System.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

Name Type
searchQuery System.String
packageIdFilter System.Collections.Generic.HashSet{System.Int32}

Returns

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