docs.unity3d.com
    Show / Hide Table of Contents

    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:

    1. Inside your Unity project window, go to Package Manager > Unity Cloud Assets.
    2. Expand the Samples section and select Import next to the Asset Discovery sample.
      Screenshot of the samples import section of the package manager window

    After the import process is complete, you can view your imported assets under the Assets/Samples/Unity Cloud Assets folder.
    Screenshot of the imported sample

    Run the sample

    To run the sample, follow these steps:

    1. 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.
    2. Select an Organization. The list of projects from that organization will be displayed on the left column.
      Screenshot of the organization selection
    3. 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.
      Screenshot of the project list
      Screenshot of the collection list

    Create a new collection

    To create a new collection, follow these steps:

    1. Ensure no collection is selected in the list.
    2. Open the context menu by clicking the ... button next to the Collections label.
      Screenshot of the context menu
    3. Click Create.
      Screenshot of creating collection popup
    4. Enter a name and a description for the collection and click Create.
      Screenshot of the created collection

    Edit an existing collection

    To edit an existing collection, follow these steps:

    1. Select one of the collections in the list.
    2. Open the context menu by clicking the ... button next to the Collections label.
      Screenshot of the context menu
    3. Click Edit.
      Screenshot of editing collection popup
    4. 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:

    1. Select one of the collections in the list.
    2. Open the context menu by clicking the ... button next to the Collections label.
      Screenshot of the context menu
    3. Click Delete.

    Add assets to a collection

    To add an asset to a collection, follow these steps:

    1. Select one of the collections in the list.
    2. Open the context menu by clicking the ... button next to the Assets in Collection label.
      Screenshot of the context menu
    3. Click Add.
      Screenshot of adding assets to collection popup
    4. Select all the assets you want to add to the collection and click Add.
      Screenshot of selected assets

    Remove assets from a collection

    To remove an asset from a collection, follow these steps:

    1. Select one of the assets in the list.
    2. Open the context menu by clicking the ... button next to the Assets in Collection label.
      Screenshot of the context menu
    3. 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.

    Login Successful

    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.

    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023