Sample: Manage asset collections
You can use the Asset discovery sample to list and manage the collections of asset in your projects.
The sample uses the collection endpoints that require 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
Before you use the Collection management sample, you must have the following:
- An installed Assets, and Identity packages > Note: While the Assets package itself doesn't depend on the Identity service, it is necessary in the sample to control the authentication flow.
- A valid Unity ID Account and access to the asset manager service
- At least 1 published asset in an Asset Management Project (see Asset Manager documentation)
Installation
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 Discovery sample.
After the import process is complete, you can view your imported assets under 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 Collection Management/Scenes/CollectionManagementSample.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. For more information on creating a Unity project, see the Asset Manager documentation. - Select an Organization. The list of projects from that organization will be displayed on the left column.
- Select a project. The list of collections for that project will be displayed in the middle column. The right column displays the list of assets for a selected collection.
Create a new collection
To create a new collection, follow these steps:
- Ensure no collection is selected in the list.
- Open the context menu by clicking the ... button next to the
Collections
label.
- Click Create.
- Enter a name and a description for the collection and click Create.
Edit an existing collection
To edit an existing collection, follow these steps:
- Select one of the collections in the list.
- Open the context menu by clicking the ... button next to the
Collections
label.
- Click Edit.
- Enter a new name and a new description for the collection and click Apply.
Delete an existing collection
To delete an existing collection, follow these steps:
- Select one of the collections in the list.
- Open the context menu by clicking the ... button next to the
Collections
label.
- Click Delete.
Add assets to a collection
To add an asset to a collection, follow these steps:
- Select one of the collections in the list.
- Open the context menu by clicking the ... button next to the
Assets in Collection
label.
- Click Add.
- Select all the assets you want to add to the collection and click Add.
Remove assets from a collection
To remove an asset from a collection, follow these steps:
- Select one of the assets in the list.
- Open the context menu by clicking the ... button next to the
Assets in Collection
label.
- Click Remove.
Main components
This section describes the scripts that make up the main components of the Asset Collection Management sample.
Platform services script
The PlatformServices
class initializes and disposes of dependencies required by the IAssetCollectionManager
. 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 Discovery sample with your Unity Gaming Services ID. For more information on authentication, see 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 collection management sample script
The CollectionManagementSample
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 published assets from the Asset Manager 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>/Asset Collection Management/Scripts/CollectionManagementSample.cs
file.
Collection list, asset list, and collection asset list UI scripts
The CollectionListUi
, AssetListUi
, and CollectionAssetListUi
classes are used to display the list of assets, collections, and assets belonging to a collection in the sample.
While the AssetPanelUi
class is used to bridge data between the AssetListUi
and CollectionAssetListUi
.
Shared UI scripts
The sample includes a set of UI scripts and prefabs used by our samples. To open shared UI scripts, go to Assets/Samples/Unity Cloud Assets/<package-version>/Shared/Scripts/Controllers
.
Troubleshoot
This section describes issues you might have while using the Asset Collection management sample.
Missing dependency
If you get a missing dependency error about a specific package, ensure you have installed all the packages listed in the Prerequisites.
The automatic browser redirection doesn't work
If you run the sample in the Unity Editor, you should see the following page after you successfully login through your browser.
If you aren't automatically redirected to the Editor and nothing happens when you select Launch Application, return to the Editor. This should continue the authentication process.
I can't see my assets
If you can't see any assets, it might be that your organization doesn't have the asset management feature flag enabled. You'll need to request access to the beta.