BeginTransientXPropertyUpdate (Unity)
- Declaration
public static CavrnusLivePropertyUpdate<Color> BeginTransientColorPropertyUpdate(this CavrnusSpaceConnection spaceConn, string containerName, string propertyName, Color propertyValue)
public static CavrnusLivePropertyUpdate<float> BeginTransientFloatPropertyUpdate(this CavrnusSpaceConnection spaceConn, string containerName, string propertyName, float propertyValue)
public static CavrnusLivePropertyUpdate<bool> BeginTransientBoolPropertyUpdate(this CavrnusSpaceConnection spaceConn, string containerName, string propertyName, bool propertyValue)
public static CavrnusLivePropertyUpdate<string> BeginTransientStringPropertyUpdate(this CavrnusSpaceConnection spaceConn, string containerName, string propertyName, string propertyValue)
public static CavrnusLivePropertyUpdate<Vector4> BeginTransientVectorPropertyUpdate(this CavrnusSpaceConnection spaceConn, string containerName, string propertyName, Vector4 propertyValue)
public static CavrnusLivePropertyUpdate<CavrnusTransformData> BeginTransientTransformPropertyUpdate(this CavrnusSpaceConnection spaceConn, string containerName, string propertyName, CavrnusTransformData propertyValue)
- Description
Begins a temporary property update. See Documentation on CavrnusLivePropertyUpdate for additional details.
Transient property updates are not saved to the Cavrnus Journal, and will not persist once everyone has left the scene. They will, however, show properly for anyone currently in the space or anyone new who joins.
The reason to do this as opposed to PostXPropertyUpdate is to reduce the size of your journal. Sometimes an interaction like dragging an object or color wheel will produce dozens or hundreds of “changes” to a property before the interaction is complete. While you will want remote users to see all of these changes, having them all individually saved to your journal is wasteful. Therefore, a CavrnusLivePropertyUpdate allows you to send those changes to other users while only saving the final value to the server.
If you are only making a single change to a property (ex: pushing a button) then PostXPropertyUpdate is preferable.
- 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;
}
}
}