Reply To: How to use BindProperty in code

NodeCanvas Forums Support How to use BindProperty in code Reply To: How to use BindProperty in code

#17142
zsoik
Participant

After you added the variable to the blackboard, an easy way to initiate a binding is by calling:

variable.BindProperty(typeof(YOUR_TARGET_TYPE).GetMember("NAME_OF_PROPERTY")[0]);

Be sure to use the correct variable type that matches your binding target. If you’re building to AoT platforms be sure that the parts you’re referencing here indirectly won’t get stripped from the build.
Also from what I know, you could just setup the bindings on a prefab then delete the binding target components from it, but you’ll have to notify the blackboard of the “binding context” at runtime in some cases (see IBlackboard.propertiesBindTarget to find out more about that) and re-bind the variables if you have to change it.