Custom Bindings
CustomBindingProviders are editor classes that tell coherence how a specific component should expose its bindings and how it generates baked scripts.
For example, we could create a custom binding provider for our Health component:
using UnityEngine;
public class Health : MonoBehaviour
{
public int health;
}using UnityEngine;
using Coherence.Toolkit;
[CustomBindingProvider(typeof(Health))]
public class HealthBindingProvider : CustomBindingProvider
{
// check the CustomBindingProvider base class to
// explore the possibilities!
}
We can add additional (custom) bindings:
Check the CustomBinding.Descriptor API for further properties, like interpolation or marking the binding as required.
CustomBindingRuntimeSerializer
For custom bindings to work on reflected mode, we need to implement how their values are serialized and deserialized at runtime:
Once we have our runtime serializer, we need to make our binding provider use it:
Extending and inheriting CustomBindingProviders
You can extend an already existing CustomBindingProvider. For example, coherence ships with a CustomBindingProvider for Transforms:
This way, you can define additional rules on how you want to treat your Transforms, for example.
Any amount of CustomBindingProviders can be registered over the same component, but only one being used. The one being used, is resolved by a priority integer that you can specify in the CustomBindingProvider attribute. The class with the higher priority defined in the attribute will be the only provider taken into account:
The default priority is set at 0, and coherence's internal CustomBindingProviders have a priority of -1.
To understand how these APIs are used, check out TransformBindingProvider and AnimatorBindingProvider, both shipped with the coherence SDK (<package>/Coherence.Editor/Toolkit/CustomBindingProviders).
Last updated
Was this helpful?

