πΉProperty Bindings
This section explains how bindable properties link data in CAS.
Overview
Property Bindings is a system for binding values in the editor. CAS uses it to link gameplay code (e.g., character controllers) with the animation system (Procedural Animation and Layered Blending).

Editor
When pressing the "+" icon, a property binding will try to search for potential bindable public fields, properties, and methods. Here is what happens on the low level:
Get a GameObject context β it is typically a player prefab reference, provided by the interface.
Iterate over all components and look for public fields, properties, and methods that return the desired type.
Create a dropdown menu with potential bindables.
Once a bindable is selected, the binding's path and component type will be updated.
To get a GameObject context, Property Bindings rely on the IBindableContext interface:
Initialization
Property Bindings needs to be manually built, which typically happens when the game starts:
Tip: The process of building bindings can be slow; it is highly recommended to build them only once when the game starts!
In some cases, it is important to create a safe copy of a property:
This can be useful when one binding is used with different instances. For example, if we bind a player-controlled offset to the animation system, we must ensure that each instance of our player has separate control over that bound property.
Getting a value
BindableProperty.GetValue() is used to return the current value of a bound property.
Tip: Property Bindings have a built-in null check for reference types, which makes it safe to use at runtime, even if one of the references is null.
BindableProperty.SetDefaultValue(T value) is used to update the default value of the property. The default value is only used when:
A property wasn't initialized successfully.
One of the references is null.
Updating context
When a binding is built during initialization, on the low level, it creates a function that takes a MonoBehaviour component as a parameter. It is possible to change the context for a property at runtime:
Tip: This is useful when we don't want to rebuild the property (because it's too expensive), but instead can change the target component to extract the bound value from.
Last updated