/
BindXPropertyValue (Unity)

BindXPropertyValue (Unity)

- Declaration

public static IDisposable BindColorPropertyValue(this CavrnusSpaceConnection spaceConn, string containerName, string propertyName, Action<Color> onPropertyUpdated)

public static IDisposable BindFloatPropertyValue(this CavrnusSpaceConnection spaceConn, string containerName, string propertyName, Action<float> onPropertyUpdated)

public static IDisposable BindBoolPropertyValue(this CavrnusSpaceConnection spaceConn, string containerName, string propertyName, Action<bool> onPropertyUpdated)

public static IDisposable BindStringPropertyValue(this CavrnusSpaceConnection spaceConn, string containerName, string propertyName, Action<string> onPropertyUpdated)

public static IDisposable BindVectorPropertyValue(this CavrnusSpaceConnection spaceConn, string containerName, string propertyName, Action<Vector4> onPropertyUpdated)

public static IDisposable BindTransformPropertyValue(this CavrnusSpaceConnection spaceConn, string containerName, string propertyName, Action<CavrnusTransformData> onPropertyUpdated)

- Description

Triggers an event when the property changes, plus an initial event when first bound.

When you are done with your Bind function and want it to stop, you should call Dispose() on the IDisposable returned by it. Otherwise it will keep triggering the event whenever changes arrive from the server.

- 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 => OnConnectedToSpace(spaceConn)); } private void OnConnectedToSpace(CavrnusSpaceConnection spaceConn) { this.spaceConn = spaceConn; spaceConn.DefineColorPropertyDefaultValue(ContainerName, PropertyName, MyMaterial.color); spaceConn.BindColorPropertyValue(ContainerName, PropertyName, c => SetMyMaterialColor(c)); } public void SetMyMaterialColor(Color color) { MyMaterial.color = color; } }

Related content

Best Practices - Designing Your Data (Unity)
Best Practices - Designing Your Data (Unity)
Read with this
BindXPropertyValue (.NET)
BindXPropertyValue (.NET)
More like this
Sample Tutorial: Training Simulation (Unity)
Sample Tutorial: Training Simulation (Unity)
Read with this
BindXPropertyValue (Unreal Engine)
BindXPropertyValue (Unreal Engine)
More like this
Sample Tutorial: Cavrnus Chess (Unity)
Sample Tutorial: Cavrnus Chess (Unity)
Read with this
BeginTransientXPropertyUpdate (Unity)
BeginTransientXPropertyUpdate (Unity)
More like this