LoadObjectAsync
method in Coherence.Cloud.CloudStorage
Methods
public StorageOperation<TObject> LoadObjectAsync<TObject>(StorageObjectId objectId, CancellationToken cancellationToken = default)
Loads an object from cloud storage.
Parameters
| Type | Name | Description |
|---|---|---|
| StorageObjectId | objectId | Identifier of the object to load. |
| CancellationToken | cancellationToken | Used to cancel the operation. |
Returns
| Type | Description |
|---|---|
| StorageOperation<TObject> | The asynchronous storage operation that will contain the loaded object. |
Type Parameters
| Name | Description |
|---|---|
| TObject | Type of the object to load. |
Examples
using Coherence.Cloud;
using UnityEngine;
class CloudStorageLoad : MonoBehaviour
{
async void Start()
{
PlayerAccount playerAccount = await PlayerAccount.GetMainAsync();
var cloudStorage = playerAccount.Services.GameServices.CloudStorage;
await cloudStorage.LoadObjectAsync<string>(("type", "id"))
.OnFail(Debug.LogWarning)
.OnSuccess(text => Debug.Log($"Loaded: '{text}'"));
}
}
Exceptions
| Type | Condition |
|---|---|
| StorageException | If the user has not logged in to coherence Cloud, the operation will fail with NotLoggedIn. If no object with the specified identifier exists in cloud storage, the operation will fail with ObjectNotFound. |