Table of Contents

SaveObjectAsync

Methods
public StorageOperation SaveObjectAsync<TObject>(StorageObjectId objectId, TObject @object, CancellationToken cancellationToken = default)

Saves an object to cloud storage.

Parameters
Type Name Description
StorageObjectId objectId

Identifier of the object to save.

TObject object

The object to save.

CancellationToken cancellationToken

Used to cancel the operation.

Returns
Type Description
StorageOperation

The status of the asynchronous save operation.

Type Parameters
Name Description
TObject

Type of the object to save.

Remarks

If an object with the id already exists in cloud storage, it will be overwritten.

Examples
using Coherence.Toolkit;
using UnityEngine;

class CloudStorageSave : MonoBehaviour
{
    public CoherenceBridge bridge = null!;

    void Start()
    {
        var cloudStorage = bridge.CloudService.GameServices.CloudStorage;
        var objectId = ("Greeter", 1);
        cloudStorage.SaveObjectAsync(objectId, "Hello, World!")
            .OnFail(Debug.LogWarning)
            .OnSuccess(() => Debug.Log("Saved"));
    }
}
Exceptions
Type Condition
StorageException

If the user is not logged in via AuthClient, the operation will fail with NotLoggedIn.