Not a Bug

Got exception when trying to run a specified macro from runtime

yyabb 4 years ago updated by Lazlo Bonin (Lead Developer) 4 years ago 1

As suggested by Bolt JasonJonesLASM,

I try to start a macro from runtime with the following code:

this.flowMachine = this.AddComponent<FlowMachine>();
flowMachine.nest.source = GraphSource.Macro;
flowMachine.nest.macro = myMacro;
flowMachine.enabled = true;

But I got this exception:

InvalidOperationException: Cannot change nested graph source after instantiation.
Ludiq.GraphNest`2[Bolt.FlowGraph,Bolt.FlowMacro].set_source (GraphSource value)

Found on Unity 1.0f3, Bolt 1.2.3, MacOS 10.12.4

Bolt Version:
Unity Version:
Scripting Backend:
.NET Version (API Compatibility Level):
Not a Bug

The missing part from that code snipped would be to deactivate the game object before adding the component, then adding it later. It's a bit hacky though, because this feature is not yet supported completely. I have plans for dynamic macros in the future, but they're not well designed yet.