Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

This class is created by calling BeginTransientXPropertyUpdate. It exists to represent a “live change” being made to a property. As such, it can repeatedly be given new data, none of which will end up in the final Journal until you call Finish().

There is logic lower down in this system to limit the rate at which messages are sent to the server. This means if you are calling UpdateWithNewData every frame, remote users will not see nearly that many updates. Doing this preserves network performance and makes it so you don’t need to limit yourself when giving changes to this object.

- Functions

Function Name

Description

UpdateWithNewData

Sends a new Transient Update updating this object’s Property to the new value

Finish

Ends the Transient calls and Posts a final value to the journal. This object will no longer be usable once this is called.

Cancel

Cancels the Transient to make it appear like this never happened. Nothing will end up in the Journal. This object will no longer be usable once this is called.

- Sample

using CavrnusSdk.API;
using UnityEngine;

public class ManageObjectColor : MonoBehaviour
{
    public Material MyMaterial;

    private const string ContainerName = "MyMaterial";
    private const string PropertyName = "color";

    private CavrnusSpaceConnection spaceConn;

    private void Start()
    {
        CavrnusFunctionLibrary.AwaitAnySpaceConnection(spaceConn => this.spaceConn = spaceConn);
    }

    private CavrnusLivePropertyUpdate<Color> liveColorUpdate = null;

    //Recv this many times as the user drags their mouse around the UI
    public void UseColorWheel(Color color)
    {
        if (liveColorUpdate == null)
        {
            liveColorUpdate = spaceConn.BeginTransientColorPropertyUpdate(ContainerName, PropertyName, color);
        }
        else
        {
            liveColorUpdate.UpdateWithNewData(color);
        }
    }

    //The user is done interacting with the color wheel
    public void ReleaseColorWheel(Color color)
    {
        if(liveColorUpdate != null)
        {
            liveColorUpdate.Finish();
            liveColorUpdate = null;
        }
    }

    //The color wheel closed and any live changes should reset back to their previous value
    public void CancelColorWheel()
    {
        if (liveColorUpdate != null)
        {
            liveColorUpdate.Cancel();
            liveColorUpdate = null;
        }
    }
}
  • No labels