DefineXPropertyDefaultValue (Unity)

- Declaration

public static void DefineColorPropertyDefaultValue(this CavrnusSpaceConnection spaceConn, string containerName, string propertyName, Color propertyValue)

public static void DefineFloatPropertyDefaultValue(this CavrnusSpaceConnection spaceConn, string containerName, string propertyName, float propertyValue)

public static void DefineBoolPropertyDefaultValue(this CavrnusSpaceConnection spaceConn, string containerName, string propertyName, bool propertyValue)

public static void DefineStringPropertyDefaultValue(this CavrnusSpaceConnection spaceConn, string containerName, string propertyName, string propertyValue)

public static void DefineVectorPropertyDefaultValue(this CavrnusSpaceConnection spaceConn, string containerName, string propertyName, Vector4 propertyValue)

public static void DefineTransformPropertyDefaultValue(this CavrnusSpaceConnection spaceConn, string containerName, string propertyName, CavrnusTransformData propertyValue)

- Description

Defines what the application will show if a new prop value has not been assigned.

This default is useful for when you call Bind for objects that already have an existing “state” built into your application. Binding to a property with no defined Default and no property assignments yet value will give you blank data (Color[0,0,0,0], etc) as its initial state. his would result in things like the transforms of built-in objects jumping to the scene origin as soon as they Bind their transform property. DefineXPropertyDefaultValue prevents this.

Once an update has been posted to the journal for this property value the default becomes irrelevant.

- 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 => MyMaterial.color = c); } }