Table of Contents

Value

struct in Coherence.Cloud

Represents the value of single StorageItem that can be saved in CloudStorage as part of a storage object.

Examples
// Copyright (c) coherence ApS.
// See the license file in the package root for more information.

using System;
using System.Linq;
using Coherence.Cloud;
using Coherence.Toolkit;
using UnityEngine;

class ValueExample : MonoBehaviour
{
    public CoherenceBridge bridge = null!;
    public StorageObjectId storageObjectId = new("Object", Guid.NewGuid());

    async void Start()
    {
        var cloudStorage = bridge.CloudService.GameServices.CloudStorage;

        StorageObject storageObject = await cloudStorage.LoadObjectAsync(storageObjectId);

        // Increment each value in the storage object by 1.
        foreach (var item in storageObject.ToArray())
        {
            storageObject[item.Key] = item.Value + 1;
        }

        // Send the storage object mutation request to cloud storage and wait for a response.
        var saveOperation = await cloudStorage.SaveObjectAsync(storageObjectId, storageObject);

        if (saveOperation.HasFailed)
        {
            Debug.LogError($"Save '{storageObjectId}' - Failed: " + saveOperation.Error);
        }
        else
        {
            Debug.Log($"Save '{storageObjectId}' - Done");
        }
    }
}
Constructors
Value

Initializes a new instance of the Value struct.

Fields
None

Represents no value.

Methods
As

Converts the serialized value into an object of type .

Equals
GetHashCode
ToString
ValueEquals
Operators
op_Equality
op_Implicit
op_Inequality