Use case: Start a transformation on a dataset
You can use the Unity Cloud Assets package to start any transformation on a given dataset. You can also fetch any previously started transformations.
The SDK supports different workflows for users with different roles:
Organization or Asset Manager Project role | List transformations | Start transformations |
---|---|---|
Asset Management Viewer |
no | no |
Asset Management Consumer |
yes | no |
Asset Management Contributor |
yes | yes |
Organization Owner |
yes | yes |
Before you start
Before you start, you must:
Set up a Unity scene in the Unity Editor with an Organization and Project browser. See 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 create assets through the dashboard; see the Managing assets on the dashboard documentation.
How do I...?
Start a transformation
To start a transformation on a dataset, follow these steps:
- Open the
AssetManagementBehaviour
script you created. - Add the following code to the end of the class:
public async Task StartTransformationOnDataset(IDataset dataset, WorkflowType workflowType)
{
try
{
var creation = new TransformationCreation
{
WorkflowType = workflowType
};
var transformation = await dataset.StartTransformationAsync(creation, CancellationToken.None);
Debug.Log($"Transformation started: {transformation.Descriptor.TransformationId}");
}
catch (Exception e)
{
Debug.LogError($"Failed to start transformation. {e}");
throw;
}
}
The code snippet starts a transformation on a selected dataset.
Get a transformation
To get a transformation that has been previously started on a dataset, whether already completed or not, follow these steps:
- Open the
AssetManagementBehaviour
script you created. - Add the following code to the end of the class:
public async Task StartTransformationOnDataset(IDataset dataset, TransformationId transformationId)
{
try
{
var transformation = await dataset.GetTransformationAsync(transformationId, CancellationToken.None);
Debug.Log($"Transformation {transformation.Descriptor.TransformationId} current status is {transformation.Status}");
}
catch (Exception e)
{
Debug.LogError($"Failed to get transformation. {e}");
throw;
}
}
The code snippet gets a transformation that has been previously started on the dataset.