docs.unity3d.com
    Show / Hide Table of Contents

    Manage assets review

    You can use the Unity Asset Manager SDK package to manage the assets.

    Asset management is available through the Asset Management pathway.

    Note: Asset management requires users have the role of Asset Management Contributor OR a minimum role of Manager in the organization.

    Before you start

    Before you start, you must:

    1. Set up a Unity scene in the Unity Editor with an organization and project browser. See either Get started with Asset Discovery or Get started with Asset Management for more information.
    2. Have some assets in the cloud. There are several ways to do so:

      • You can create assets through the Get started with Asset Management.
      • You can upload assets from existing Unity assets; see the Asset Database Uploader sample.
      • You can create assets through the dashboard; see the Managing assets on the dashboard documentation.

    How do I...?

    Send an asset to review

    To send an asset to review:

    1. Open the AssetManagementBehaviour script you created.
    2. Add the following code to the end of the class:
    
    public async Task SendAssetToReview()
    {
        var cancellationTokenSrc = new CancellationTokenSource(k_DefaultCancellationTimeout);
        try
        {
            await PlatformServices.AssetManager.SendAssetToReviewAsync(CurrentAsset, cancellationTokenSrc.Token);
    
            await UpdateCurrentAsset();
        }
        catch (Exception e)
        {
            Debug.LogError($"Failed to send asset to review: {CurrentAsset.Name}. {e.Message}");
        }
    }
    
    

    The script sends an asset in the cloud to review.

    Approve an in-review asset

    To approve an in-review asset:

    1. Open the AssetManagementBehaviour script you created.
    2. Add the following code to the end of the class:
    
    public async Task ApproveInReviewAsset()
    {
        var cancellationTokenSrc = new CancellationTokenSource(k_DefaultCancellationTimeout);
        try
        {
            await PlatformServices.AssetManager.ApproveAssetAsync(CurrentAsset, cancellationTokenSrc.Token);
    
            await UpdateCurrentAsset();
        }
        catch (Exception e)
        {
            Debug.LogError($"Failed to approve in-review asset: {CurrentAsset.Name}. {e.Message}");
        }
    }
    
    

    The script approves an in-review asset.

    Reject an in-review asset

    To reject an in-review asset:

    1. Open the AssetManagementBehaviour script you created.
    2. Add the following code to the end of the class:
    
    public async Task RejectInReviewAsset()
    {
        var cancellationTokenSrc = new CancellationTokenSource(k_DefaultCancellationTimeout);
        try
        {
            await PlatformServices.AssetManager.RejectAssetAsync(CurrentAsset, cancellationTokenSrc.Token);
    
            await UpdateCurrentAsset();
        }
        catch (Exception e)
        {
            Debug.LogError($"Failed to reject in-review asset: {CurrentAsset.Name}. {e.Message}");
        }
    }
    
    

    The script rejects an in-review asset.

    Add the UI for interacting with assets

    To add UI for the example:

    1. Open the AssetManagementUI script you created.
    2. Replace the AdditionalActions function with the following code:
    
    protected virtual void AdditionalActions()
    {
        if (m_Behaviour.CurrentAsset == null)
        {
            GUILayout.Label(" ! No asset selected !");
            return;
        }
    
        if(string.Equals(m_Behaviour.CurrentAsset.Status, "Draft", StringComparison.OrdinalIgnoreCase))
        {
            if (GUILayout.Button("Send to Review"))
            {
                _ = m_Behaviour.SendAssetToReview();
            }
            GUILayout.Space(5f);
        }
        else if(string.Equals(m_Behaviour.CurrentAsset.Status, "Ingestion", StringComparison.OrdinalIgnoreCase))
        {
            if (GUILayout.Button("Approve in-review asset"))
            {
                _ = m_Behaviour.ApproveInReviewAsset();
            }
            GUILayout.Space(5f);
    
            if (GUILayout.Button("Reject in-review asset"))
            {
                _ = m_Behaviour.RejectInReviewAsset();
            }
            GUILayout.Space(5f);
        }
    }
    
    

    The script provides UI buttons to trigger the send to review or approve in-review or reject in-review an asset.

    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