docs.unity3d.com
    Show / Hide Table of Contents

    Interface IAssetManager

    An interface that provides all the methods to interact with an IAsset.

    Namespace: Unity.Cloud.Assets
    Syntax
    public interface IAssetManager

    Methods

    AggregateAsync(IAssetSearchFilter, AggregationParameters, CancellationToken)

    Implement this method to get a count of assets that satisfy the search criteria.

    Declaration
    Task<Aggregation> AggregateAsync(IAssetSearchFilter assetSearchFilter, AggregationParameters parameters, CancellationToken token)
    Parameters
    Type Name Description
    IAssetSearchFilter assetSearchFilter

    The object containing the parameters for the asset search.

    AggregationParameters parameters

    The object containing the necessary information for aggregation.

    CancellationToken token

    The cancellation token

    Returns
    Type Description
    Task<Aggregation>

    A task whose result is a count of assets that satisfy the assetSearchFilter.

    Examples
    async Task<Aggregation> AggregateAssets(IProject project, string assetName, CancellationToken cancellationToken)
    {
        var assetSearchFilter = new AssetSearchFilter(project);
        assetSearchFilter.Project.Include(project);
    
        var aggregationParameters = new AggregationParameters(nameof(IAsset.Project), 20);
    
        var aggregation = await m_AssetManager.AggregateAsync(assetSearchFilter, aggregationParameters, cancellationToken);
        return aggregation;
    }
    
    async Task<Aggregation> AggregateAssets(IOrganization organization, IEnumerable<IProject> projects,string assetName, CancellationToken cancellationToken)
    {
        var assetSearchFilter = new AssetSearchFilter(null);
    
        var aggregationParameters = new AggregationParameters(nameof(IAsset.Project), 20);
    
        var aggregation = await m_AssetManager.AggregateAsync(organization, projects, assetSearchFilter, aggregationParameters, cancellationToken);
        return aggregation;
    }

    AggregateAsync(IOrganization, IEnumerable<IProject>, IAssetSearchFilter, AggregationParameters, CancellationToken)

    Implement this method to get a count of assets across specified projects that satisfy the search criteria.

    Declaration
    Task<Aggregation> AggregateAsync(IOrganization organization, IEnumerable<IProject> projects, IAssetSearchFilter assetSearchFilter, AggregationParameters parameters, CancellationToken token)
    Parameters
    Type Name Description
    IOrganization organization

    The organization in which the projects are.

    IEnumerable<IProject> projects

    The id of the projects in which to search.

    IAssetSearchFilter assetSearchFilter

    The object containing the parameters for the asset search.

    AggregationParameters parameters

    The object containing the necessary information for aggregation.

    CancellationToken token

    The cancellation token

    Returns
    Type Description
    Task<Aggregation>

    A task whose result is a count of assets that satisfy the assetSearchFilter.

    Examples
    async Task<Aggregation> AggregateAssets(IProject project, string assetName, CancellationToken cancellationToken)
    {
        var assetSearchFilter = new AssetSearchFilter(project);
        assetSearchFilter.Project.Include(project);
    
        var aggregationParameters = new AggregationParameters(nameof(IAsset.Project), 20);
    
        var aggregation = await m_AssetManager.AggregateAsync(assetSearchFilter, aggregationParameters, cancellationToken);
        return aggregation;
    }
    
    async Task<Aggregation> AggregateAssets(IOrganization organization, IEnumerable<IProject> projects,string assetName, CancellationToken cancellationToken)
    {
        var assetSearchFilter = new AssetSearchFilter(null);
    
        var aggregationParameters = new AggregationParameters(nameof(IAsset.Project), 20);
    
        var aggregation = await m_AssetManager.AggregateAsync(organization, projects, assetSearchFilter, aggregationParameters, cancellationToken);
        return aggregation;
    }

    ApproveAssetAsync(IAsset, CancellationToken)

    Implement this method to approve an asset in review.

    Declaration
    Task ApproveAssetAsync(IAsset asset, CancellationToken token)
    Parameters
    Type Name Description
    IAsset asset

    The asset.

    CancellationToken token

    The cancellation token

    Returns
    Type Description
    Task

    A task with no result.

    Examples
    async Task ApproveAssetAsync(IAsset asset, CancellationToken cancellationToken)
    {
        await m_AssetManager.ApproveAssetAsync(asset, cancellationToken);
    }

    CheckProjectIsAssetSourceProjectAsync(IAsset, CancellationToken)

    Implement this method to check if the project is an asset source project.

    Declaration
    Task<bool> CheckProjectIsAssetSourceProjectAsync(IAsset asset, CancellationToken token)
    Parameters
    Type Name Description
    IAsset asset

    The asset.

    CancellationToken token

    The cancellation token

    Returns
    Type Description
    Task<Boolean>

    A task with a boolean. True if asset's project is the source. False otherwise

    Examples
    async Task<bool> CheckProjectIsAssetSourceProject(IAsset asset, CancellationToken cancellationToken)
    {
        var isAssetSourceProject = await m_AssetManager.CheckProjectIsAssetSourceProjectAsync(asset, cancellationToken);
        return isAssetSourceProject;
    }

    CreateAssetAsync(IAssetCreation, CancellationToken)

    Implement this method to create an asset.

    Declaration
    Task<IAsset> CreateAssetAsync(IAssetCreation assetCreation, CancellationToken token)
    Parameters
    Type Name Description
    IAssetCreation assetCreation

    The object containing the necessary information to create an IAsset.

    CancellationToken token

    The cancellation token

    Returns
    Type Description
    Task<IAsset>

    A task with no result.

    Examples
    async Task<IAsset> CreateAsset(AssetCreation assetCreation, CancellationToken cancellationToken)
    {
        var asset = await m_AssetManager.CreateAssetAsync(assetCreation, cancellationToken);
        return asset;
    }

    DeleteAssetAsync(IAsset, CancellationToken)

    Implement this method to delete an asset.

    Declaration
    Task DeleteAssetAsync(IAsset asset, CancellationToken token)
    Parameters
    Type Name Description
    IAsset asset

    The asset to delete.

    CancellationToken token

    The cancellation token

    Returns
    Type Description
    Task

    A task with no result.

    Examples
    async Task DeleteAsset(IAsset asset, CancellationToken cancellationToken)
    {
        await m_AssetManager.DeleteAssetAsync(asset, cancellationToken);
    }

    GetAssetAsync(IProject, String, Int32, CancellationToken)

    Implement this method to get a single IAsset.

    Declaration
    Task<IAsset> GetAssetAsync(IProject project, string assetId, int assetVersion, CancellationToken token)
    Parameters
    Type Name Description
    IProject project

    The id of the project the assetId belongs to.

    String assetId

    The id of the asset to retrieve.

    Int32 assetVersion

    The version number of the asset.

    CancellationToken token

    The cancellation token

    Returns
    Type Description
    Task<IAsset>

    A task whose result is the requested IAsset.

    Examples
    async Task<IAsset> GetAsset(IProject project, string assetId, int assetVersion, CancellationToken cancellationToken)
    {
        var asset = await m_AssetManager.GetAssetAsync(project, assetId, assetVersion, cancellationToken);
        return asset;
    }

    GetAssetAsync<TAsset>(IProject, String, Int32, CancellationToken)

    Implement this method to get a single asset of type TAsset.

    Declaration
    Task<TAsset> GetAssetAsync<TAsset>(IProject project, string assetId, int assetVersion, CancellationToken token)
        where TAsset : IAsset, new()
    Parameters
    Type Name Description
    IProject project

    The id of the project the assetId belongs to.

    String assetId

    The id of the asset to retrieve.

    Int32 assetVersion

    The version number of the asset.

    CancellationToken token

    The cancellation token

    Returns
    Type Description
    Task<TAsset>

    A task whose result is the requested IAsset.

    Type Parameters
    Name Description
    TAsset

    A type which inherits from IAsset.

    Examples
    async Task<Asset> GetAsset_GenericType(IProject project, string assetId, int assetVersion, CancellationToken cancellationToken)
    {
        var asset = await m_AssetManager.GetAssetAsync<Asset>(project, assetId, assetVersion, cancellationToken);
        return asset;
    }

    GetAssetCollectionsAsync(IAsset, CancellationToken)

    Implement this method to get the asset collections.

    Declaration
    Task GetAssetCollectionsAsync(IAsset asset, CancellationToken token)
    Parameters
    Type Name Description
    IAsset asset

    The the asset.

    CancellationToken token

    The cancellation token

    Returns
    Type Description
    Task

    A task with no result.

    Examples
    async Task GetAssetCollectionsAsync(IAsset asset, CancellationToken cancellationToken)
    {
        await m_AssetManager.GetAssetCollectionsAsync(asset, cancellationToken);
    }

    GetAssetDownloadUrlsAsync(IAsset, CancellationToken)

    Implement this method to get the asset download urls.

    Declaration
    Task GetAssetDownloadUrlsAsync(IAsset asset, CancellationToken token)
    Parameters
    Type Name Description
    IAsset asset

    The the asset.

    CancellationToken token

    The cancellation token

    Returns
    Type Description
    Task

    A task with no result.

    Examples
    async Task GetAssetDownloadUrls(IAsset asset, CancellationToken cancellationToken)
    {
        await m_AssetManager.GetAssetDownloadUrlsAsync(asset, cancellationToken);
    }

    LinkAnAssetToProjectAsync(IAsset, UInt64, String, CancellationToken)

    Implement this method to get the asset download urls.

    Declaration
    Task LinkAnAssetToProjectAsync(IAsset asset, ulong destinationOrganizationId, string destinationProjectId, CancellationToken token)
    Parameters
    Type Name Description
    IAsset asset

    The asset.

    UInt64 destinationOrganizationId

    The destination organization id.

    String destinationProjectId

    The destination project id.

    CancellationToken token

    The cancellation token

    Returns
    Type Description
    Task

    A task with no result.

    Examples
    async Task LinkAnAssetToProject(IAsset asset, IOrganization destinationOrganization, IProject destinationProject, CancellationToken cancellationToken)
    {
        await m_AssetManager.LinkAnAssetToProjectAsync(asset, destinationOrganization.GenesisId, destinationProject.Id, cancellationToken);
    }

    PublishApprovedAssetAsync(IAsset, CancellationToken)

    Implement this method to publish an approved asset.

    Declaration
    Task PublishApprovedAssetAsync(IAsset asset, CancellationToken token)
    Parameters
    Type Name Description
    IAsset asset

    The asset.

    CancellationToken token

    The cancellation token

    Returns
    Type Description
    Task

    A task with no result.

    Examples
    async Task PublishApprovedAsset(IAsset asset, CancellationToken cancellationToken)
    {
        await m_AssetManager.PublishApprovedAssetAsync(asset, cancellationToken);
    }

    RejectAssetAsync(IAsset, CancellationToken)

    Implement this method to reject an asset in review.

    Declaration
    Task RejectAssetAsync(IAsset asset, CancellationToken token)
    Parameters
    Type Name Description
    IAsset asset

    The asset.

    CancellationToken token

    The cancellation token

    Returns
    Type Description
    Task

    A task with no result.

    Examples
    async Task RejectAssetAsync(IAsset asset, CancellationToken cancellationToken)
    {
        await m_AssetManager.RejectAssetAsync(asset, cancellationToken);
    }

    SearchAsync(IAssetSearchFilter, Pagination, CancellationToken)

    Implement this method to get a collection of assets that satisfy the search criteria.

    Declaration
    IAsyncEnumerable<IAsset> SearchAsync(IAssetSearchFilter assetSearchFilter, Pagination pagination, CancellationToken token)
    Parameters
    Type Name Description
    IAssetSearchFilter assetSearchFilter

    The object containing the parameters for the asset search.

    Pagination pagination

    An object containing the necessary information return a range of IAsset matching the search criteria.

    CancellationToken token

    The cancellation token

    Returns
    Type Description
    IAsyncEnumerable<IAsset>

    A task whose result is an async enumeration of IAsset.

    Examples
    IAsyncEnumerable<IAsset> SearchForAssets(IProject project, string assetName, CancellationToken cancellationToken)
    {
        var assetSearchFilter = new AssetSearchFilter(project);
        assetSearchFilter.Name.Include(assetName);
    
        var pagination = new Pagination(nameof(IAsset.VersionName), Range.All);
    
        var assets = m_AssetManager.SearchAsync(assetSearchFilter, pagination, cancellationToken);
        return assets;
    }
    
    IAsyncEnumerable<IAsset> SearchForAssets(IOrganization organization, IEnumerable<IProject> projects, string assetName, CancellationToken cancellationToken)
    {
        var assetSearchFilter = new AssetSearchFilter(null);
        assetSearchFilter.Name.Include(assetName);
    
        var pagination = new Pagination(nameof(IAsset.VersionName), Range.All);
    
        var assets = m_AssetManager.SearchAsync(organization, projects, assetSearchFilter, pagination, cancellationToken);
        return assets;
    }

    SearchAsync(IOrganization, IEnumerable<IProject>, IAssetSearchFilter, Pagination, CancellationToken)

    Implement this method to get a collection of assets across specified projects that satisfy the search criteria.

    Declaration
    IAsyncEnumerable<IAsset> SearchAsync(IOrganization organization, IEnumerable<IProject> projects, IAssetSearchFilter assetSearchFilter, Pagination pagination, CancellationToken token)
    Parameters
    Type Name Description
    IOrganization organization

    The organization in which the projects are.

    IEnumerable<IProject> projects

    The id of the projects in which to search.

    IAssetSearchFilter assetSearchFilter

    The object containing the parameters for the asset search.

    Pagination pagination

    An object containing the necessary information return a range of IAsset matching the search criteria.

    CancellationToken token

    The cancellation token

    Returns
    Type Description
    IAsyncEnumerable<IAsset>

    A task whose result is an async enumeration of IAsset.

    Examples
    IAsyncEnumerable<IAsset> SearchForAssets(IProject project, string assetName, CancellationToken cancellationToken)
    {
        var assetSearchFilter = new AssetSearchFilter(project);
        assetSearchFilter.Name.Include(assetName);
    
        var pagination = new Pagination(nameof(IAsset.VersionName), Range.All);
    
        var assets = m_AssetManager.SearchAsync(assetSearchFilter, pagination, cancellationToken);
        return assets;
    }
    
    IAsyncEnumerable<IAsset> SearchForAssets(IOrganization organization, IEnumerable<IProject> projects, string assetName, CancellationToken cancellationToken)
    {
        var assetSearchFilter = new AssetSearchFilter(null);
        assetSearchFilter.Name.Include(assetName);
    
        var pagination = new Pagination(nameof(IAsset.VersionName), Range.All);
    
        var assets = m_AssetManager.SearchAsync(organization, projects, assetSearchFilter, pagination, cancellationToken);
        return assets;
    }

    SearchAsync<TAsset>(IAssetSearchFilter, Pagination, CancellationToken)

    Implement this method to get a collection of assets that satisfy the search criteria.

    Declaration
    IAsyncEnumerable<TAsset> SearchAsync<TAsset>(IAssetSearchFilter assetSearchFilter, Pagination pagination, CancellationToken token)
        where TAsset : IAsset, new()
    Parameters
    Type Name Description
    IAssetSearchFilter assetSearchFilter

    The object containing the parameters for the asset search.

    Pagination pagination

    An object containing the necessary information return a range of IAsset matching the search criteria.

    CancellationToken token

    The cancellation token

    Returns
    Type Description
    IAsyncEnumerable<TAsset>

    A task whose result is an async enumeration of IAsset.

    Type Parameters
    Name Description
    TAsset

    A type which inherits from IAsset.

    Examples
    IAsyncEnumerable<IAsset> SearchForAssets_GenericType(IProject project, string assetName, CancellationToken cancellationToken)
    {
        var assetSearchFilter = new AssetSearchFilter(project);
        assetSearchFilter.Name.Include(assetName);
    
        var pagination = new Pagination(nameof(IAsset.VersionName), Range.All);
    
        var assets = m_AssetManager.SearchAsync<Asset>(assetSearchFilter, pagination, cancellationToken);
        return assets;
    }
    
    IAsyncEnumerable<IAsset> SearchForAssets_GenericType(IOrganization organization, IEnumerable<IProject> projects, string assetName, CancellationToken cancellationToken)
    {
        var assetSearchFilter = new AssetSearchFilter(null);
        assetSearchFilter.Name.Include(assetName);
    
        var pagination = new Pagination(nameof(IAsset.VersionName), Range.All);
    
        var assets = m_AssetManager.SearchAsync<Asset>(organization, projects, assetSearchFilter, pagination, cancellationToken);
        return assets;
    }

    SearchAsync<TAsset>(IOrganization, IEnumerable<IProject>, IAssetSearchFilter, Pagination, CancellationToken)

    Implement this method to get a collection of assets across specified projects that satisfy the search criteria.

    Declaration
    IAsyncEnumerable<TAsset> SearchAsync<TAsset>(IOrganization organization, IEnumerable<IProject> projects, IAssetSearchFilter assetSearchFilter, Pagination pagination, CancellationToken token)
        where TAsset : IAsset, new()
    Parameters
    Type Name Description
    IOrganization organization

    The organization in which the projects are.

    IEnumerable<IProject> projects

    The id of the projects in which to search.

    IAssetSearchFilter assetSearchFilter

    The object containing the parameters for the asset search.

    Pagination pagination

    An object containing the necessary information return a range of IAsset matching the search criteria.

    CancellationToken token

    The cancellation token

    Returns
    Type Description
    IAsyncEnumerable<TAsset>

    A task whose result is an async enumeration of IAsset.

    Type Parameters
    Name Description
    TAsset

    A type which inherits from IAsset.

    Examples
    IAsyncEnumerable<IAsset> SearchForAssets_GenericType(IProject project, string assetName, CancellationToken cancellationToken)
    {
        var assetSearchFilter = new AssetSearchFilter(project);
        assetSearchFilter.Name.Include(assetName);
    
        var pagination = new Pagination(nameof(IAsset.VersionName), Range.All);
    
        var assets = m_AssetManager.SearchAsync<Asset>(assetSearchFilter, pagination, cancellationToken);
        return assets;
    }
    
    IAsyncEnumerable<IAsset> SearchForAssets_GenericType(IOrganization organization, IEnumerable<IProject> projects, string assetName, CancellationToken cancellationToken)
    {
        var assetSearchFilter = new AssetSearchFilter(null);
        assetSearchFilter.Name.Include(assetName);
    
        var pagination = new Pagination(nameof(IAsset.VersionName), Range.All);
    
        var assets = m_AssetManager.SearchAsync<Asset>(organization, projects, assetSearchFilter, pagination, cancellationToken);
        return assets;
    }

    SendAssetToReviewAsync(IAsset, CancellationToken)

    Implement this method to send an asset to review.

    Declaration
    Task SendAssetToReviewAsync(IAsset asset, CancellationToken token)
    Parameters
    Type Name Description
    IAsset asset

    The asset.

    CancellationToken token

    The cancellation token

    Returns
    Type Description
    Task

    A task with no result.

    Examples
    async Task SendAssetToReviewAsync(IAsset asset, CancellationToken cancellationToken)
    {
        await m_AssetManager.SendAssetToReviewAsync(asset, cancellationToken);
    }

    UnlinkAssetFromProjectAsync(IAsset, CancellationToken)

    Implement this method to unlink the asset from the project.

    Declaration
    Task UnlinkAssetFromProjectAsync(IAsset asset, CancellationToken token)
    Parameters
    Type Name Description
    IAsset asset

    The asset.

    CancellationToken token

    The cancellation token

    Returns
    Type Description
    Task

    A task with no result.

    Examples

    UpdateAssetAsync(IAsset, CancellationToken)

    Implement this method to update an asset.

    Declaration
    Task UpdateAssetAsync(IAsset asset, CancellationToken token)
    Parameters
    Type Name Description
    IAsset asset

    The asset you want to update.

    CancellationToken token

    The cancellation token

    Returns
    Type Description
    Task

    A task with no result.

    Examples
    async Task UpdateAsset(IAsset asset, CancellationToken cancellationToken)
    {
        await m_AssetManager.UpdateAssetAsync(asset, cancellationToken);
    }

    WithdrawPublishedAssetAsync(IAsset, CancellationToken)

    Implement this method to withdraw an published asset.

    Declaration
    Task WithdrawPublishedAssetAsync(IAsset asset, CancellationToken token)
    Parameters
    Type Name Description
    IAsset asset

    The asset.

    CancellationToken token

    The cancellation token

    Returns
    Type Description
    Task

    A task with no result.

    Examples
    async Task WithdrawPublishedAsset(IAsset asset, CancellationToken cancellationToken)
    {
        await m_AssetManager.WithdrawPublishedAssetAsync(asset, cancellationToken);
    }
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023