Reply To: Switch SubTree asset at runtime and connect its’ exposed parameters to parent?

NodeCanvas Forums Support Switch SubTree asset at runtime and connect its’ exposed parameters to parent? Reply To: Switch SubTree asset at runtime and connect its’ exposed parameters to parent?

#16234
bwohaha
Participant

After some experiments I’ve come up with this code solution. Sudo-code:

var varDriven = keyValuePair.Value;

var bbParam = new BBMappingParameter(varDriven);

bbParam.canRead = true;

bbParam.canWrite = true;

bbParam.useBlackboard = true;

bbParam.bb = graphParent.blackboard;

bbParam.SetTargetVariable(graphParent.blackboard, varDriver);

 

subtree.variablesMap.Add(bbParam);

With it I should be able to write a custom ActionTask that will auto-fill and connect all of the SubTree exposed vars with ParentGraph’s vars, meaning I can swap assets during prefab creation at least.
Still, if there’s a better way to do it – I’m all ears.