BindToLocalUserMetadataJson (Unity)
public static IDisposable BindToLocalUserMetadataJson(this CavrnusUser user, string key, Action<JObject> onMetadataChanged)
- Description
Binds local user JSON metadata via key-value lookup where key is. Triggers when the metadata value updates.
Â
For more information on user metadata, see INSERTPAGE for details.
- Sample
using CavrnusSdk.API;
using UnityEngine;
public class ExampleScript: MonoBehaviour
{
public void Start()
{
CavrnusFunctionLibrary.AwaitAnySpaceConnection(sc => {
sc.AwaitLocalUser(lu => {
lu.BindToLocalUserMetadataJson("newJson", val => {
if (val == null)
return;
var r = val["r"].Value<float>();
var g = val["g"].Value<float>();
var b = val["b"].Value<float>();
var a = val["a"].Value<float>();
var receivedColor = new Color(r, g, b, a);
// Output the received color
Debug.Log($"Received Color: {receivedColor}");
});
});
});
}
}