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 ContributorOR a minimum role ofManagerin the organization.
Before you start
Before you start, you must:
- 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.
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:
- Open the
AssetManagementBehaviourscript you created. - 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:
- Open the
AssetManagementBehaviourscript you created. - 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:
- Open the
AssetManagementBehaviourscript you created. - 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:
- Open the
AssetManagementUIscript you created. - Replace the
AdditionalActionsfunction 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.