StorageItem
struct in Coherence.Cloud
Represents a single item in a storage object.
Examples
// Copyright (c) coherence ApS.
// See the license file in the package root for more information.
using System;
using Coherence.Cloud;
using Coherence.Toolkit;
using UnityEngine;
class StorageItemExample : 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);
// Foreach can be used to enumerate all items in a loaded storage object.
foreach (StorageItem storageItem in storageObject)
{
Debug.Log($"Item: {storageItem}");
}
// StorageItem can be implicitly converted into a (Key, Value) tuple.
foreach ((Key key, Value value) in storageObject)
{
Debug.Log($"Item: {key}: {value}");
}
// StorageItem's key can also be implicitly converted into a string,
// and its value into various simple types like string or int.
foreach ((string key, int value) in storageObject)
{
Debug.Log($"Item: {key}: {value}");
}
// Likewise, tuples can be implicitly converted into storage items.
StorageItem item = ("Key", 1);
Debug.Log($"Item: {item}");
}
}
Constructors
StorageItem | Initializes a new instance of the StorageItem struct. |
Properties
Key | Gets the key of the storage item. |
Value | Gets the value of the storage item. |
Methods
Deconstruct | |
Equals | |
GetHashCode | |
ToString |
Operators
op_Equality | |
op_Implicit | |
op_Inequality |