Sample: Discover assets
You can use the Asset Discovery sample to search and download assets from your Organizations and Projects.
You can use the Unity Cloud Assets package to filter assets in a Project based on a set of search criteria. You will need at least a Consumer Role to be able to download assets
Organization or Asset Manager Project role | Search | Download |
---|---|---|
Asset Management Viewer |
yes | No |
Asset Management Consumer |
yes | yes |
Asset Management Contributor |
yes | yes |
Organization Owner |
yes | yes |
Before you start
Before you use the Asset Discovery sample, you must have the following:
- Installed Assets package
- Installed Identity package
- A valid Unity ID Account
- Access to your Unity Gaming Services account
- Access to Asset Manager service
- At least one asset in an Asset Management Project, see: Asset Manager documentation
- 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:
In your Unity Project window, go to Package Manager > Unity Cloud Assets.
Expand the Samples section.
On the right of the Asset Discovery sample, select Import.
After the import process is complete, you can view your imported assets in the
Assets/Samples/Unity Cloud Assets
folder.
Run the sample
To run the sample, follow these steps:
- Go to
Assets/Samples/Unity Cloud Assets/<package-version>/Asset Discovery/Scenes/AssetDiscoverySample.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 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, select it. The search bar will add it as a parameter and the sample will refresh the asset list to match the new search.
See asset details and download files
To see your asset information in this sample, select one of the assets in the grid. The asset details view appears.
The details view shows you the following information about your asset:
- Name
- Description
- Tags
- System tags
- Collections
- Authoring information: creation date and last modified date
- Metadata
To download your asset information in this sample, follow these steps:
- Select one of the assets in the grid. The asset details view appears.
- In the details view, select Download.
To change the location of the downloaded asset, update the path
variable in AssetInformationPanelController.OnAssetDownloadButtonClicked()
.
async void OnAssetDownloadButtonClicked()
{
UpdateDownloadButton(false);
var path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
Note
To download assets, you need the right permissions in your Project to consume assets. Refer to the the Asset Manager documentation for more information on permissions.
Main components
This section describes the scripts that make up the main components of the Asset Discovery 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 Discovery 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 Discovery sample script
The AssetDiscoverySample
shows you how to do the following:
- Integrate the login flow with the
ProjectController
class. - Retrieve Organizations and Projects from the Assets service.
- Retrieve assets from the Assets service.
- Search for assets by tag or name.
To open the Asset Discovery sample script, go to your Assets/Samples/Unity Cloud Assets/<package-version>/AssetDiscovery/Scripts/AssetDiscoverySample.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
.
Go further with your sample
This section describes other actions you can perform with the Asset Discovery sample.
Troubleshooting
Refer to the troubleshooting section for help with sample issues.