- Declaration
public static IDisposable BindColorPropertyValue(this CavrnusSpaceConnection spaceConn, string containerName, string propertyName, Action<Color> 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.TODO: EXPLAIN DISPOSAL OR MAKE IT UNNESSESARY
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
Code Block | ||
---|---|---|
| ||
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; } } |