Use case: Search assets across projects
You can use the Unity Cloud Assets package to filter assets across projects based on a set of search criteria.
Organization or Asset Manager Project role | Cross-project search |
---|---|
Asset Management Viewer |
yes |
Asset Management Consumer |
yes |
Asset Management Contributor |
yes |
Organization Owner |
yes |
Methodology
To search assets across projects, you can use one of two QueryAssets
method of an IAssetRepository
.
To search assets across all projects of an organization, call the following method:
IAsyncEnumerable<IAsset> SearchAsync(OrganizationId organizationId, IAssetSearchFilter searchFilter)
{
return m_AssetRepository.QueryAssets(organizationId)
.SelectWhereMatchesFilter(searchFilter)
.ExecuteAsync(CancellationToken.None);
}
To search assets across a select set of projects, call the following method:
IAsyncEnumerable<IAsset> SearchAsync(IEnumerable<ProjectDescriptor> projectDescriptors, IAssetSearchFilter searchFilter)
{
return m_AssetRepository.QueryAssets(projectDescriptors)
.SelectWhereMatchesFilter(searchFilter)
.ExecuteAsync(CancellationToken.None);
}
In both examples, the ExecuteAsync
method returns an awaitable IAsyncEnumerable
that will return each IAsset
result.
Built-in Search Filter
For more information on the IAssetSearchFilter
, see Use case: Search assets in a project.