Is it possible to add a visual script graph component directly to a gameobject at runtime using C#?
Senario: I have two script graphes named “test_a.asset” and “test_b.asset”. I would like to use C# to decide and add one of the script graph to a gameobject at runtime.
I know Unity has a Scripting API: GameObject.AddComponent, but I am not sure what params to pass. It seems I need to create a ScriptMachine with the graph asset path somehow, but I failed to find the implementation detail.
I also realised that there is a node called “SetScriptGraph”, but I cannot pass the graph asset path to it.
Load it first and then pass in the actual asset? Lots of ways of loading assets in Unity from path. Resources.Load would probably be the simplest but ideally you’d use something like Addressables for it.