Get started with Asset SDK
Asset Manager is a Unity Cloud service that allows you to manage your assets in the cloud. You can use Assets SDK to:
- Create and read an Asset Project.
- Create, read, and update:
- assets
- datasets
- files
- Download files.
- Create, read, update, and delete collections.
- Search your Assets in an Asset Project or Organization based on a set of criteria.
- Group and count Assets based on a set of criteria.
- Link and unlink Assets from Projects.
- Link and unlink Assets from Collections.
- Start transformations on datasets.
- Create, read, update and delete the Field Definitions of an Organization.
- Add and remove the accepted values of Field Definitions of the
Selection
type.
This section explains how to set up a basic scene and script to initialize and use the Unity Assets package with Asset Manager. It performs a basic search for all assets of the selected project and displays the results in a simple GUI.
Before you begin, make sure you meet the prerequisites.
Requirements
To use Assets SDK, you must have a minimum role of Asset Manager Viewer in the Unity Cloud Project you belong to.
Integrate the package in a Unity project
To integrate the Unity Cloud Assets package in a Unity project, you must do the following:
- Set up a Unity scene
- Create the
PlatformServices
Set up a Unity scene
To set up a Unity scene, follow these steps:
- In your Unity project window, navigate to Assets > Scenes.
- Select and hold the
Assets/Scenes
folder and navigate to Create > Scene. - Name the new scene
AssetManagementExample
.
Create an AssetManager
To create a MonoBehaviour
, follow these steps:
- In your Unity project window, go to Assets > Scripts. Create an
Assets/Scripts
folder if the folder doesn't already exist. - Select and hold the
Assets/Scripts
folder. - Go to Create > C# Script. Name your script
AssetManagementUI
. - In the
AssetManagementExample
scene you created earlier, select and hold the hierarchy and select Create Empty. - Name your new object
AssetManager
. - Select the
AssetManager
object and add theAssetManagementUI
script you created earlier.
Create the PlatformServices
To instantiate the necessary components, follow these steps:
- Implement the platform services pattern. See the Best practices: dependency injection page of the Identity package documentation for more information.
- Update the
PlatformServices
class in yourPlatformServices.cs
file to look like the following:
using System;
using System.Threading.Tasks;
using Unity.Cloud.Assets;
using Unity.Cloud.Common;
using Unity.Cloud.Common.Runtime;
using Unity.Cloud.Identity;
using Unity.Cloud.Identity.Runtime;
public static class PlatformServices
{
/// <summary>
/// Returns a <see cref="ICompositeAuthenticator"/>.
/// </summary>
public static ICompositeAuthenticator Authenticator { get; private set; }
/// <summary>
/// Returns a <see cref="IAuthenticationStateProvider"/>.
/// </summary>
public static IAuthenticationStateProvider AuthenticationStateProvider => Authenticator;
/// <summary>
/// Returns an <see cref="IOrganizationRepository"/>.
/// </summary>
public static IOrganizationRepository OrganizationRepository => Authenticator;
/// <summary>
/// Returns an <see cref="IAssetRepository"/>.
/// </summary>
public static IAssetRepository AssetRepository { get; private set; }
public static void Create()
{
var httpClient = new UnityHttpClient();
var serviceHostResolver = UnityRuntimeServiceHostResolverFactory.Create();
var playerSettings = UnityCloudPlayerSettings.Instance;
var platformSupport = PlatformSupportFactory.GetAuthenticationPlatformSupport();
var compositeAuthenticatorSettings = new CompositeAuthenticatorSettingsBuilder(httpClient, platformSupport, serviceHostResolver, playerSettings)
.AddDefaultPkceAuthenticator(playerSettings)
.Build();
Authenticator = new CompositeAuthenticator(compositeAuthenticatorSettings);
var serviceHttpClient = new ServiceHttpClient(httpClient, Authenticator, playerSettings);
AssetRepository = AssetRepositoryFactory.Create(serviceHttpClient, serviceHostResolver);
}
/// <summary>
/// A Task that initializes all platform services.
/// </summary>
/// <returns>A Task.</returns>
public static async Task InitializeAsync()
{
await Authenticator.InitializeAsync();
}
/// <summary>
/// Shuts down all platform services.
/// </summary>
public static void ShutDownServices()
{
(Authenticator as IDisposable)?.Dispose();
Authenticator = null;
}
}
What this script accomplishes:
- Initializes an
ICompositeAuthenticator
for logging in and verifying your identity when accessing the HTTP services. - Initializes an
IOrganizationRepository
to fetch the organizations you belong to. - Initializes an
IAssetRepository
to interface with the Asset Manager service.
To initialize the PlatformServices
in your scene, follow these steps:
- In your Unity Project window, go to Assets > Scripts.
- Select and hold the
Assets/Scripts
folder. - Go to Create > C# Script. Name your script
PlatformServicesInitialization
. - In the
AssetManagementExample
scene you created earlier, select and hold the hierarchy and select Create Empty. - Name your new object
PlatformServices
. - Select the
PlatformServices
object and add thePlatformServicesInitialization
script you created earlier. - Update the
PlatformServicesInitialization
class in yourPlatformServicesInitialization.cs
file to look like the following:
using System.Threading.Tasks;
using UnityEngine;
/// <summary>
/// A Mono behaviour class to initialize services and dependencies for the Unity Cloud platform.
/// </summary>
[DefaultExecutionOrder(int.MinValue)]
public class PlatformServicesInitialization : MonoBehaviour
{
void Awake()
{
DontDestroyOnLoad(gameObject);
PlatformServices.Create();
}
async Task Start()
{
await PlatformServices.InitializeAsync();
}
}
What this script accomplishes:
- Triggers the creation of the services available in the
PlatformServices
. - Initializes the
ICompositeAuthenticator
.
To clean up the PlatformServices
in your scene, follow these steps:
- In your Unity Project window, go to Assets > Scripts.
- Select and hold the
Assets/Scripts
folder. - Go to Create > C# Script. Name your script
PlatformServicesShutdown
. - Select the
PlatformServices
object you created earlier and add thePlatformServicesShutdown
script you created earlier. - Update the
PlatformServicesShutdown
class in yourPlatformServicesShutdown.cs
file to look like the following:
using UnityEngine;
/// <summary>
/// A Mono behaviour class to shut down services and dependencies from the Unity Cloud platform.
/// </summary>
[DefaultExecutionOrder(int.MaxValue)]
public class PlatformServicesShutdown : MonoBehaviour
{
void OnDestroy()
{
PlatformServices.ShutDownServices();
}
}
This script cleans up of the services when the scene is closed.
Create the behaviour for managing assets
To create the behaviour for asset management, follow these steps:
- In your Unity Project window, go to Assets > Scripts.
- Select and hold the
Assets/Scripts
folder. - Go to Create > C# Script. Name your script
AssetManagementBehaviour
. - Open the
AssetManagementBehaviour
script you created and replace the contents of the file with the following code sample:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Unity.Cloud.Assets;
using Unity.Cloud.Identity;
using UnityEngine;
public class AssetManagementBehaviour
{
const int k_DefaultCancellationTimeout = 5000;
IOrganization[] m_AvailableOrganizations;
CancellationTokenSource m_ProjectCancellationTokenSrc = new();
CancellationTokenSource m_AssetCancellationTokenSrc = new();
public IOrganization[] AvailableOrganizations => m_AvailableOrganizations;
public IOrganization CurrentOrganization { get; private set; }
public bool IsOrganizationSelected => CurrentOrganization != null;
public List<IAssetProject> AvailableProjects { get; } = new();
public IAssetProject CurrentProject { get; private set; }
public bool IsProjectSelected => CurrentProject != null;
public List<IAsset> AvailableAssets { get; } = new();
public IAsset CurrentAsset { get; set; }
public void Clear()
{
m_ProjectCancellationTokenSrc.Cancel();
m_ProjectCancellationTokenSrc.Dispose();
m_AssetCancellationTokenSrc.Cancel();
m_AssetCancellationTokenSrc.Dispose();
CurrentAsset = null;
CurrentProject = null;
CurrentOrganization = null;
}
public void SetSelectedOrganization(IOrganization organization)
{
CurrentAsset = null;
CurrentProject = null;
CurrentOrganization = organization;
if (CurrentOrganization != null)
{
_ = GetProjectsAsync();
}
}
public void SetSelectedProject(IAssetProject project)
{
CurrentAsset = null;
CurrentProject = project;
if (CurrentProject != null)
{
_ = GetAssetsAsync();
}
}
public async Task GetOrganizationsAsync()
{
m_AvailableOrganizations = null;
try
{
var organizations = new List<IOrganization>();
var organizationsAsyncEnumerable = PlatformServices.OrganizationRepository.ListOrganizationsAsync(Range.All);
await foreach (var organization in organizationsAsyncEnumerable)
{
organizations.Add(organization);
}
m_AvailableOrganizations = organizations.ToArray();
}
catch (OperationCanceledException oe)
{
Debug.Log(oe);
}
catch (AggregateException e)
{
Debug.LogError(e.InnerException);
}
catch (Exception e)
{
Debug.LogError(e);
}
}
public async Task CreateAssetAsync(AssetType assetType)
{
var assetCreation = new AssetCreation("GrayTexture_0")
{
Description = "Documentation example asset creation.",
Type = assetType
};
var cancellationTokenSrc = new CancellationTokenSource(k_DefaultCancellationTimeout);
try
{
var asset = await CurrentProject.CreateAssetAsync(assetCreation, cancellationTokenSrc.Token);
if (asset != null)
{
_ = GetAssetsAsync();
}
}
catch (Exception e)
{
Debug.LogError($"Failed to create asset. {e}");
throw;
}
}
public async Task UpdateAssetAsync(IAsset asset, IAssetUpdate assetUpdate)
{
try
{
var cancellationTokenSrc = new CancellationTokenSource(k_DefaultCancellationTimeout);
await asset.UpdateAsync(assetUpdate, cancellationTokenSrc.Token);
await asset.RefreshAsync(cancellationTokenSrc.Token);
}
catch (OperationCanceledException oe)
{
Debug.Log(oe);
}
catch (AggregateException e)
{
Debug.LogError(e.InnerException);
}
catch (Exception e)
{
Debug.LogError(e);
}
}
public async Task GetProjectsAsync()
{
m_ProjectCancellationTokenSrc.Cancel();
m_ProjectCancellationTokenSrc.Dispose();
m_ProjectCancellationTokenSrc = new CancellationTokenSource();
try
{
var token = m_ProjectCancellationTokenSrc.Token;
var projects = PlatformServices.AssetRepository.ListAssetProjectsAsync(CurrentOrganization.Id, Range.All, token);
AvailableProjects.Clear();
CurrentProject = null;
await foreach (var project in projects)
{
AvailableProjects.Add(project);
}
}
catch (OperationCanceledException oe)
{
Debug.Log(oe);
}
catch (AggregateException e)
{
Debug.LogError(e.InnerException);
}
catch (Exception e)
{
Debug.LogError(e);
}
}
async Task GetAssetsAsync()
{
m_AssetCancellationTokenSrc.Cancel();
m_AssetCancellationTokenSrc.Dispose();
m_AssetCancellationTokenSrc = new CancellationTokenSource();
try
{
var token = m_AssetCancellationTokenSrc.Token;
var assets = CurrentProject.QueryAssets().ExecuteAsync(token);
AvailableAssets.Clear();
CurrentAsset = null;
await foreach (var asset in assets)
{
AvailableAssets.Add(asset);
}
}
catch (OperationCanceledException oe)
{
Debug.Log(oe);
}
catch (AggregateException e)
{
Debug.LogError(e.InnerException);
}
catch (Exception e)
{
Debug.LogError(e);
}
}
}
The script does the following:
- Provides the functions to list and select Organizations.
- Provides the functions to list and select Projects.
- Performs a basic search to list the assets of the selected Project.
- Provides the functions to create, read, update, delete assets.
Create an interface for all UI scripts
To create the interface for all UI scripts, follow these steps:
- In your Unity Project window, go to Assets > Scripts.
- Select and hold the
Assets/Scripts
folder. - Go to Create > C# Script. Name your script
IAssetManagementUI
. - Open the
IAssetManagementUI
script you created earlier and replace the contents of the file with the following code sample:
public interface IAssetManagementUI
{
public void OnGUI();
}
Create the UI for selecting an organization
To create a simple UI for selecting an organization, do the following:
- In your Unity Project window, go to Assets > Scripts.
- Select and hold the
Assets/Scripts
folder. - Go to Create > C# Script. Name your script
OrganizationSelectionExampleUI
. - Open the
OrganizationSelectionExampleUI
script you created and replace the contents of the file with the following code sample:
using System;
using UnityEngine;
public class OrganizationSelectionExampleUI : IAssetManagementUI
{
readonly AssetManagementBehaviour m_Behaviour;
public OrganizationSelectionExampleUI(AssetManagementBehaviour behaviour)
{
m_Behaviour = behaviour;
}
public void OnGUI()
{
if (m_Behaviour.IsOrganizationSelected) return;
// Refresh the org list
if (GUILayout.Button("Refresh"))
{
_ = m_Behaviour.GetOrganizationsAsync();
return;
}
GUILayout.Space(15f);
// If an organization is not selected, list those available.
SelectAnOrganization();
}
void SelectAnOrganization()
{
GUILayout.BeginVertical();
GUILayout.Label("Available Organizations:");
GUILayout.Space(5f);
var availableOrganizations = m_Behaviour.AvailableOrganizations;
if (availableOrganizations != null)
{
for (var i = 0; i < availableOrganizations.Length; ++i)
{
if (GUILayout.Button(availableOrganizations[i].Name))
{
m_Behaviour.SetSelectedOrganization(availableOrganizations[i]);
}
}
}
else
{
GUILayout.Label("Loading...");
}
GUILayout.EndVertical();
}
}
The script does the following:
- Provides the UI to list and select organizations.
Create the UI for selecting a project
To create a simple UI for selecting a project, do the following:
- In your Unity Project window, go to Assets > Scripts.
- Select and hold the
Assets/Scripts
folder. - Go to Create > C# Script. Name your script
ProjectSelectionExampleUI
. - Open the
ProjectSelectionExampleUI
script you created and replace the contents of the file with the following code sample:
using System;
using UnityEngine;
public class ProjectSelectionExampleUI : IAssetManagementUI
{
readonly AssetManagementBehaviour m_Behaviour;
Vector2 m_ProjectListScrollPosition;
public ProjectSelectionExampleUI(AssetManagementBehaviour behaviour)
{
m_Behaviour = behaviour;
}
public void OnGUI()
{
if (!m_Behaviour.IsOrganizationSelected || m_Behaviour.IsProjectSelected) return;
GUILayout.BeginVertical();
// Go back to select a different scene.
if (GUILayout.Button("Back"))
{
m_Behaviour.SetSelectedOrganization(null);
return;
}
// Refresh the project list
if (GUILayout.Button("Refresh"))
{
_ = m_Behaviour.GetProjectsAsync();
return;
}
GUILayout.EndVertical();
GUILayout.Space(15f);
SelectAProject();
}
void SelectAProject()
{
GUILayout.BeginVertical();
GUILayout.Label($"{m_Behaviour.CurrentOrganization.Name}");
GUILayout.Space(15f);
GUILayout.Label("Available Projects:");
GUILayout.Space(5f);
var projects = m_Behaviour.AvailableProjects;
if (projects.Count > 0)
{
m_ProjectListScrollPosition = GUILayout.BeginScrollView(m_ProjectListScrollPosition, GUILayout.Height(Screen.height * 0.8f));
for (var i = 0; i < projects.Count; ++i)
{
if (GUILayout.Button(projects[i].Name))
{
m_Behaviour.SetSelectedProject(projects[i]);
}
}
GUILayout.EndScrollView();
}
else
{
GUILayout.Label("No projects found.");
}
GUILayout.EndVertical();
}
}
The script does the following:
- Provides the UI to list and select projects.
Create the UI for selecting an asset
To create a simple UI for selecting an asset, do the following:
- In your Unity Project window, go to Assets > Scripts.
- Select and hold the
Assets/Scripts
folder. - Go to Create > C# Script. Name your script
AssetSelectionExampleUI
. - Open the
AssetSelectionExampleUI
script you created and replace the contents of the file with the following code sample:
using System;
using UnityEngine;
public class AssetSelectionExampleUI : IAssetManagementUI
{
readonly AssetManagementBehaviour m_Behaviour;
Vector2 m_AssetListScrollPosition;
public AssetSelectionExampleUI(AssetManagementBehaviour behaviour)
{
m_Behaviour = behaviour;
}
public void OnGUI()
{
if (!m_Behaviour.IsProjectSelected) return;
// Go back to select a different scene.
if (GUILayout.Button("Back"))
{
m_Behaviour.SetSelectedProject(null);
return;
}
GUILayout.Space(15f);
GUILayout.BeginVertical();
GUILayout.Label($"{m_Behaviour.CurrentOrganization.Name} >> {m_Behaviour.CurrentProject.Name}");
GUILayout.Space(15f);
SelectAnAsset();
GUILayout.EndVertical();
}
void SelectAnAsset()
{
var width = Screen.width * 0.25f;
GUILayout.Label("Available Assets:");
GUILayout.Space(5f);
var assets = m_Behaviour.AvailableAssets;
if (assets.Count > 0)
{
m_AssetListScrollPosition = GUILayout.BeginScrollView(m_AssetListScrollPosition, GUILayout.Height(Screen.height * 0.8f));
for (var i = 0; i < assets.Count; ++i)
{
if (GUILayout.Button(assets[i].Name, GUILayout.Width(width)))
{
m_Behaviour.CurrentAsset = assets[i];
Debug.Log($"Selected: {assets[i].Descriptor.AssetId}");
}
}
GUILayout.EndScrollView();
}
else
{
GUILayout.Label("No assets found.");
}
}
}
The script does the following:
- Provides the UI to list and select assets.
Create the UI for CRUD operations on assets
To create a simple UI for CRUD operations on assets, do the following:
- In your Unity Project window, go to Assets > Scripts.
- Select and hold the
Assets/Scripts
folder. - Go to Create > C# Script. Name your script
UseCaseCreateAssetExampleUI
. - Open the
UseCaseCreateAssetExampleUI
script you created and replace the contents of the file with the following code sample:
using Unity.Cloud.Assets;
using UnityEngine;
public class UseCaseCreateAssetExampleUI : IAssetManagementUI
{
readonly AssetManagementBehaviour m_Behaviour;
readonly string[] m_AssetTypeList;
AssetType m_SelectedType = AssetType.Other;
public UseCaseCreateAssetExampleUI(AssetManagementBehaviour behaviour)
{
m_Behaviour = behaviour;
m_AssetTypeList = AssetTypeExtensions.AssetTypeList().ToArray();
}
public void OnGUI()
{
if (!m_Behaviour.IsProjectSelected) return;
GUILayout.BeginVertical();
GUILayout.BeginHorizontal();
GUILayout.Label("Type: ");
var type = (int) m_SelectedType;
type = GUILayout.SelectionGrid(type, m_AssetTypeList, 4);
if (type != -1)
m_SelectedType = (AssetType) type;
GUILayout.EndHorizontal();
if (GUILayout.Button("Create new asset", GUILayout.Width(150f)))
{
_ = m_Behaviour.CreateAssetAsync(m_SelectedType);
}
GUILayout.EndVertical();
}
}
- In your Unity Project window, go to Assets > Scripts.
- Select and hold the
Assets/Scripts
folder. - Go to Create > C# Script. Name your script
UseCaseManageAssetExampleUI
. - Open the
UseCaseManageAssetExampleUI
script you created and replace the contents of the file with the following code sample:
using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Unity.Cloud.Assets;
using UnityEngine;
public class UseCaseManageAssetExampleUI : IAssetManagementUI
{
readonly AssetManagementBehaviour m_Behaviour;
readonly string[] m_AssetTypeList;
IAsset m_CurrentAsset;
AssetUpdate m_AssetUpdate;
public UseCaseManageAssetExampleUI(AssetManagementBehaviour behaviour)
{
m_Behaviour = behaviour;
m_AssetTypeList = AssetTypeExtensions.AssetTypeList().ToArray();
}
public void OnGUI()
{
if (!m_Behaviour.IsProjectSelected) return;
GUILayout.Space(15f);
GUILayout.BeginVertical();
if (m_Behaviour.CurrentAsset == null)
{
GUILayout.Label(" ! No asset selected !");
}
else
{
if (m_Behaviour.CurrentAsset != m_CurrentAsset)
{
m_CurrentAsset = m_Behaviour.CurrentAsset;
m_AssetUpdate = null;
_ = RefreshAssetAsync(m_CurrentAsset);
}
GUILayout.Label("Asset selected:");
GUILayout.Space(5f);
if (m_AssetUpdate == null)
{
GUILayout.Label("Loading...");
}
else
{
DisplayAsset(m_CurrentAsset, m_AssetUpdate);
}
}
GUILayout.EndVertical();
}
async Task RefreshAssetAsync(IAsset asset)
{
await asset.RefreshAsync(CancellationToken.None);
m_AssetUpdate = new AssetUpdate(asset);
}
void DisplayAsset(IAsset asset, AssetUpdate assetUpdate)
{
GUILayout.BeginHorizontal();
GUILayout.Label("Name:");
assetUpdate.Name = GUILayout.TextField(assetUpdate.Name, GUILayout.Width(100f));
GUILayout.Space(5f);
GUILayout.Label(asset.Status);
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
GUILayout.Label("Type: ");
var type = assetUpdate.Type.HasValue ? (int) assetUpdate.Type.Value : -1;
type = GUILayout.SelectionGrid(type, m_AssetTypeList, 4);
if (type != -1)
assetUpdate.Type = (AssetType) type;
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
GUILayout.Label("Tags: ");
var tags = string.Join(',', assetUpdate.Tags);
tags = GUILayout.TextField(tags);
assetUpdate.Tags = tags.Split(',').ToList();
GUILayout.EndHorizontal();
if (GUILayout.Button("Update"))
{
_ = m_Behaviour.UpdateAssetAsync(asset, assetUpdate);
}
}
}
The scripts do the following:
- Provide UI buttons to select an asset type and a UI button to create a new asset.
- Provide UI to update the name, type and tags of the selected asset.
Integrate the UI scripts
To bring all your UI scripts into a single Monobehaviour
, open the AssetManagementUI
script you created earlier and replace the contents of the file with the following code sample:
using System;
using System.Collections.Generic;
using Unity.Cloud.Identity;
using UnityEngine;
public class AssetManagementUI : MonoBehaviour
{
protected readonly AssetManagementBehaviour m_Behaviour = new();
protected readonly List<IAssetManagementUI> m_UI = new();
IAuthenticationStateProvider m_AuthenticationStateProvider;
bool IsLoggedIn => m_AuthenticationStateProvider?.AuthenticationState == AuthenticationState.LoggedIn;
protected virtual void Awake()
{
m_UI.Add(new OrganizationSelectionExampleUI(m_Behaviour));
m_UI.Add(new ProjectSelectionExampleUI(m_Behaviour));
m_UI.Add(new AssetSelectionExampleUI(m_Behaviour));
m_UI.Add(new UseCaseCreateAssetExampleUI(m_Behaviour));
m_UI.Add(new UseCaseManageAssetExampleUI(m_Behaviour));
}
void Start()
{
m_AuthenticationStateProvider = PlatformServices.AuthenticationStateProvider;
m_AuthenticationStateProvider.AuthenticationStateChanged += OnAuthenticationStateChanged;
}
void OnDestroy()
{
if (m_AuthenticationStateProvider != null)
{
m_AuthenticationStateProvider.AuthenticationStateChanged -= OnAuthenticationStateChanged;
}
m_Behaviour.Clear();
}
void OnGUI()
{
GUILayout.BeginHorizontal(GUILayout.Width(Screen.width));
UpdateAuthenticationUI(m_AuthenticationStateProvider.AuthenticationState);
if (!IsLoggedIn)
{
GUILayout.EndHorizontal();
return;
}
foreach (var ui in m_UI)
{
ui.OnGUI();
}
AdditionalGUI();
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
}
protected virtual void AdditionalGUI()
{
// Do more stuff here.
}
static void UpdateAuthenticationUI(AuthenticationState state)
{
GUILayout.BeginVertical();
switch (state)
{
case AuthenticationState.AwaitingInitialization:
GUILayout.Label("Initializing Service...");
break;
case AuthenticationState.AwaitingLogout:
GUILayout.Label("Logging out...");
break;
case AuthenticationState.LoggedOut:
if (GUILayout.Button("Login"))
{
_ = PlatformServices.Authenticator.LoginAsync();
}
break;
case AuthenticationState.AwaitingLogin:
GUILayout.Label("Logging in...");
if (GUILayout.Button("Cancel"))
{
PlatformServices.Authenticator.CancelLogin();
}
break;
case AuthenticationState.LoggedIn:
if (GUILayout.Button("Logout"))
{
_ = PlatformServices.Authenticator.LogoutAsync();
}
break;
default:
throw new ArgumentOutOfRangeException(nameof(state), state, null);
}
GUILayout.EndVertical();
}
void OnAuthenticationStateChanged(AuthenticationState obj)
{
if (obj == AuthenticationState.LoggedIn)
{
_ = m_Behaviour.GetOrganizationsAsync();
}
}
}
The script does the following:
- Registers to the
ICompositeAuthenticator
to track login changes. - Creates an instance of an
AssetManagementBehaviour
. - Creates instances of the UI scripts for selecting an organization, project, and asset.
Going further
For a more information about asset management, see the Asset Management sample.
Creating datasets
By default, each asset contain two datasets:
Sources
Previews
To create additional datasets, see the Create datasets use case for more information.
Uploading files
See the Upload files use case for more information.
Grouping assets in collections
Collections allow assets to be group together within a project. See the Manage collections use case for more information.