NodeCanvas Forums › Support › How to add a bound property or field to Blackboard via script? › Reply To: How to add a bound property or field to Blackboard via script?
Hello,
Here is how you can create a variable and then bind it to a property or field.
1 2 3 4 5 6 7 8 9 10 11 12 13 | //The test property public bool isDead; [ContextMenu("DO")] public void Do(){ var bb = GetComponent<Blackboard>(); var variable = bb.AddVariable("isDead", isDead); //1st parameter is the PropertyInfo or FieldInfo. //2nd parameter is the "target" gameobject which has a component which that property/field resides. variable.BindProperty( this.GetType().GetField("isDead"), this.gameObject ); } |
Let me know if that works for you.
Thank you.