Sample: Manage assets
The sample available as part of the Unity Cloud Assets demonstrates how to update and publish assets. A typical example of audience for this guide is the developers who want to integrate asset management features in their app.
The sample use the management endpoints that requires a minimum role of:
Before you start
To use the Asset Management sample, you need the following:
- Installed Assets package
- Installed Identity package
- A valid Unity ID Account
- Access to your Unity Gaming Services account
- An access to the Asset Manager service
- A Unity Project with the Asset Manager service enabled, see: Asset Manager documentation
Note
While the Assets package doesn't depend on the Identity service, it is used in the sample to control the authentication process.
Install the sample
To install the sample, follow these steps:
- Inside your Unity Project window, go to Package Manager > Unity Cloud Assets.
- Expand the Samples section.
- On the right of the Asset Management sample, select Import.
After the import process completes, you can view the imported assets in the Unity Cloud Assets/Samples/Samples/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/AssetManagerSample.unity
and run the scene. - Select an Organization. The list of Projects from that Organization appears on the left column.
- Select a Project. The list of assets from that Project appears on the right column.
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 by which you want to search your assets and select Search.
Note
While using the SDK, you will be able to build different and more complex queries. 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 select a keyword, select it. The search bar will add it as a parameter and the sample will refresh the asset list to match the new search.
Update/edit an asset
To update an asset in this sample, follow these steps:
- Select a Project.
- On the right side of the screen, select ... button of the asset you want to update and select Open.
- In the asset details page, edit the asset's information and select the Save asset button. Add metadata to the asset by selecting 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, you can select the desired dataset.
- In the dataset details page, edit the dataset's information and select the Save dataset button.
- In the dataset details page, you can start a workflow to generate a thumbnail by selecting the Generate preview button. This will create a new dataset containing an image file.
- To add a new file to the dataset, select the Browse button, select the desired file. If a dataset possesses at least one file, you can generate a preview image by selecting Generate Preview button.
- To remove a file from the dataset, select the Trash icon button.
- To go back to the detail of the asset, select the Back button on the top left corner.
- To go back to the list of assets of the Project, select the Back button on the top left corner.
Note
When an asset is not published, you can do the two following actions :
- You can save the asset by selecting the Save asset button.
- You can publish it by checking the Publish checkbox and selecting the Publish asset button.
- Sources dataset is the default dataset of an asset used to list the asset data files.
- Previews dataset is default dataset of an asset to list the asset preview files.
Main components
This section describes the scripts that make up the main components of the Asset Management sample.
Platform services script
The PlatformServices
class initializes and disposes of dependencies required by the IAssetRepository
. You can use this class to manage the 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 accompanying 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 makes it so you can sign into 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 also uses the IAssetRepository
of the PlatformServices
to retrieve the list of projects you have access to for 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
shows you how to do the following:
- Integrate the 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.