Search Unity

Question Is there a generally accepted workflow for using graphs without Monobehaviours?

Discussion in 'Visual Scripting' started by scott_mk, Dec 8, 2022.

  1. scott_mk

    scott_mk

    Joined:
    Sep 1, 2021
    Posts:
    5
    I'm experimenting with using the Visual Scripting Editor for designers to generate graphs using an if this then that workflow supported via custom Units we have written.

    At runtime I basically just need to trigger a graph to have the flow run and execute any relevant units inside of it.

    If I use either a UnitEvent<T> or the prebuilt custom event as the "entrypoint" to the graph and call
    EventBus.Trigger(EventNames.MyCustomEvent, 2) or
    CustomEvent.Trigger(gameObject, "EventNames.MyCustomEvent, 2) then neither of these run unless I have a ScriptMachine attached to some relevant GameObject.

    Ideally I would like to do something like:
    1. Get reference to relevant graph (via SerializedFields, Resources.Load, Addressables etc.)
    2. graph.Execute(); or some other workflow.
    3. (Optionally) pull variables out of the graph when done.
    1 & 3 seem fine as I can (in a test scene) have a serialized reference to a graph and then use the variables.Get functions to pull out any information I need. But I'm stuck on finding a good way to just have the graph execute without having to create some dummy Monobehaviour and add a ScriptMachine to it.

    Is there a non Monobehaviour machine available, or some other way I could be triggering them directly from the graph asset itself?
     
  2. PanthenEye

    PanthenEye

    Joined:
    Oct 14, 2013
    Posts:
    2,076
    This incarnation of the tool was designed entirely for Unity newbies/non-coders. That level of data driven workflows aren't natively supported. Unity are working on supporting this type of workflow in their next major version of the tool which by their own words will land in 2-3 years.