Reply To: Accessing a FlowCanvas graph from script?

FlowCanvas Forums Support Accessing a FlowCanvas graph from script? Reply To: Accessing a FlowCanvas graph from script?

#2173
Gavalakis
Keymaster

Hello 🙂

Yes, it’s possible to call FlowCanvas Custom Functions as well as access (get/set) Blackboard variables in code.

To call a Custom Function:
– Get a reference to the FlowScriptController component attached on your gameobject and call the “CallFunction” method, like for example:
GetComponent<FlowScriptController>().CallFunction("MyFunction");.
Please note, that you can also pass parameters, if your Custom Function does take parameters, but there parameters need to be passed in correct order, like for example:
GetComponent<FlowScriptController>().CallFunction("MyFunction", 10.5f, true)

To access Blackboard and get/set their value:
– Get a reference to the Blackboard component attached on the gameobject and use either ‘GetValue’ or ‘SetValue’ methods, like for example:
var number = GetComponent<Blackboard>().GetValue<float>("myFloat");
or:
GetComponent<Blackboard>().SetValue("myFloat", 10.5f);

Please let me know if that works for you.
Thanks!

Join us on Discord: https://discord.gg/97q2Rjh