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 pages