Sample: Manage assets
The sample available as part of the Unity Asset Manager SDK 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:
- Manager in the Unity Cloud Organization you belong to.
OR - Asset Manager Contributor in the Unity Cloud Project you belong to.
Before you start
To use the Asset Management sample, you need the following:
- An installed Assets package
- An installed Identity package
- A valid Unity ID 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 flow.
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 and select Import next to the Asset Management sample.
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. If this is your first time launching the sample, make sure to sign in with your Unity Gaming Services account. - Select an Organization. The list of projects from that organization appears on the left column.
- Select a project. The list of published 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 manual.
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, click on 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.
- To go back to the list of assets of the project, select the desired project in the project list.
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.
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 AssetManager
. 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()
.
User Controller script
The UserController
class lets you sign in and provides the Asset Management sample with your Unity Gaming Services ID. For more information on authentication, see the Get user information page of the Identity package documentation.
To open the UserController script, go to your Assets/Samples/Unity Cloud Assets/<package-version>/Shared/Scripts/Controllers/UserController.cs
file.
Asset Management sample script
The AssetManagerSample
shows you how to do the following:
- Integrate the login flow with the
UserController
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 Asset Manager SDK 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.