Sample: Manage assets
This sample is available as a part of Unity Cloud Assets and enables users to update and publish assets. An example of an audience for this guide are developers who want to integrate asset management features in their app.
Before you start
To use the Asset Management sample, make sure you meet the following prerequisites:
Roles and permissions
The sample uses management endpoints that require you to have any one of the below roles:
Prerequisites
- Installed Assets package
- Installed Identity package
- A valid Unity ID Account
- Access to your Unity Gaming Services account
- Access to Asset Manager service
- A Unity Project with Asset Manager services enabled, see: Asset Manager documentation
Note
The Assets package doesn't depend on the Identity service, however, it's used in the sample to control the authentication process.
Install the sample
To install the sample, follow these steps:
In the Unity Editor, go to the top menu bar, select Window.
Select Package Manager. The package manager window opens.
From the Packages list, select Unity Cloud Assets.
On the right side, select the Samples tab.
In the section below, go to Asset Management and select the Import button.
After the import process is complete, you can view the imported sample in the
Assets/Samples/Unity Cloud Assets/<package-version>/Asset Management
folder.
Run the sample
To run the sample, follow these steps:
- Go to
Assets/Samples/Unity Cloud Assets/<package-version>/Asset Management/Scenes
folder. Open AssetManagerSample.unity and run the scene.
Note
Ensure that you are logged in to access your Projects. To log in, follow these steps:
1. Select the Login button on the top right side. This action redirects you to a web browser.
2. Select the Allow Login Request button. The browser displays Login completed successfully. You can close the browser and go back to the Unity Editor.
- Select an Organization. The list of Projects in this Organization appear on the left panel.
- Select a Project. The list of assets in this Project and their details appear in a table.
Search for specific assets
To search for specific assets by tag or name in this sample, follow these steps:
- Select a Project.
- In the search bar, type the keywords you want to use to search for your assets.
- Select Search.
Note
You can build different and more complex queries while using the SDK. For more information on asset search, see the Search Assets use case.
Search prompts
As you type in the search bar, the sample will display a list of keyword suggestions based on your search. These keywords are aggregated from the tags and names of your assets. To pick a keyword, select it. The search bar adds it as a parameter and the sample refreshes the asset list to match the new search.
Update/edit an asset
You can update an asset only if it's unfrozen and in Draft status. To update an asset in this sample, follow these steps:
- Select a Project. The list of assets in this project appear in a table.
- Go to the last column of the table , select the ... button for the asset you want to update.
- Select Open. The asset details page opens.
- Edit the asset's information and select the Save asset button.
- To add metadata to the asset, select the Add Metadata button.
- To add a new dataset to the asset, select the Create dataset button. A new dataset with an automatic name is added to the asset.
- To update a dataset or manage the files of an asset, select the dataset you want. The dataset details page opens.
- Edit the dataset's information and select the Save dataset button.
- To start a workflow to generate a thumbnail, select the Generate thumbnail button. This will create a new dataset containing an image file.
- To add a new file to the dataset, select the Browse button and select the desired file. If a dataset has at least one file, you can generate a preview image. Select the Generate preview button.
- To remove a file from the dataset, select the delete icon.
- To go back to a previous page, on the top left corner, select the Back button.
Note
When an asset is unfrozen, you can do the following actions :
To save the asset, select the Save changes button.
To publish the asset, select the Publish button.
To freeze the asset, select the Save version button.
- Sources dataset is a default dataset of an asset. It lists the asset data files.
- Previews dataset is a default dataset of an asset. It lists the asset preview files.
When an asset is frozen, you can do the following actions :
To publish the asset, select the Publish button.
To create a new version based off the current version, select the Continue editing button.
- Sources dataset is a default dataset of an asset. It lists the asset data files.
- Previews dataset is a default dataset of an asset. It lists the asset preview files.
Browse the asset's version history
By default, the details panel displays the list of datasets for the default version of the asset. To browse the asset's version history in this sample, follow these steps once an asset is selected:
- To browse the asset's version history, select the History tab.
- In the asset's version history, you can select a version to view its details.
- To go back to the asset's datasets, select the Datasets tab.
Main components
This section describes the scripts that form the main components of the Asset Management sample.
Platform services script
The PlatformServices
class initializes and disposes dependencies required by the IAssetRepository
. You can use this class to manage Unity Cloud services and dependencies you use in your application.
To open the platform services script, go to your Assets/Samples/Unity Cloud Assets/<package-version>/Shared/Scripts/Services/PlatformServices.cs
file.
The PlatformServices
class has two associated classes called PlatformServicesInitialization
and PlatformServicesShutdown
that call the initialization and shutdown methods through Unity's standard Monobehaviour
methods Awake()
, Start()
and OnDestroy()
.
Project controller script
The ProjectController
class inherits from the OrganizationController
class which enables signing in to your application and uses your ID to grant access to the Asset Management sample. For more information on authentication, see the Get user information use case in the Identity package documentation.
The ProjectController
class uses the IOrganizationRepository
of the PlatformServices
to retrieve the list of organizations you have access to.
The ProjectController
class uses the IAssetRepository
of the PlatformServices
to retrieve the list of projects you have access to in the selected organization.
To open the project controller script, go to your Assets/Samples/Unity Cloud Assets/<package-version>/Shared/Scripts/Controllers/ProjectController.cs
file.
Asset Management sample script
The AssetManagerSample
script helps you with the following:
- Integrate login flow with the
ProjectController
class - Retrieve Organizations and Projects from the Asset Manager service
- Retrieve assets from the Asset Manager service and manage them
- Search for assets by tag or name
To open the Asset Management sample script, go to your Assets/Samples/Unity Cloud Assets/<package-version>/AssetManager/Scripts/AssetManagerSample.cs
file.
Shared UI scripts
The UI
sample includes a set of UI scripts and prefabs used by Unity Cloud Assets samples. To open shared UI scripts, go to Assets/Samples/Unity Cloud Assets/<package-version>/Shared/Scripts/Controllers
.
Troubleshooting
Refer to the troubleshooting section for help with sample issues.