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 »

- 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.

TODO: EXPLAIN DISPOSAL OR MAKE IT UNNESSESARY

- 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;
    }
}
  • No labels