Can user create/modify Behavior graph at runtime?

Hi,

I work for an industry customer. We are exploring the use of Behavior package to describe training scenarios. Right now, we make the scenario in Unity before building the app.

In the futur, we would like to let advanced users (instructors that aren’t developpers and doesn’t know Unity) build their own scenario using the 3D world and custom graph actions we provide. That way, trainees could load new created scenarios and receive training content without me having to do any work :wink:

At runtime (Windows desktop only), we would like:

  • A way to display Behavior graphs
  • A way for user to add/edit/remove actions/conditions/flows in graphs
  • A way to save new created graphs (with the already existing JSON serialization)
  • No need for editing Blackboard, we will provide a shared blackboard with all possible objects, advanced users will be limited to that.

Is it possible to have an equivalent to Behavior Editor window in a built player?
I think it’s not possible at the moment, is it planned to have this? I’ve seen Behavior uses App-UI (that uses UI-Toolkit underground), which are made to be editor and also runtime compatible.
Is there any technical incompatibility to know if we have to do it by ourselves?

Hi @Pitou22 ,

At the moment most of the relevant APIs are internal only due to various reasons including:

  • Not wanting to commit to them yet as we didn’t really design them for users yet.
  • Lack of documentation.
  • Maintenance once exposed to users.

That said, you could move the package locally and make them public. @Darren_Kelly worked with Struckd to use Behavior for its custom logic and you can see an example there where the entire graph is exposed.

At this time we’re not at the point we can prioritize exposing all these APIs so you may need to make the modifications locally. Sorry that’s probably not a great answer.

Do note most of the UI (except for stuff that’s made to create source files or interact with the asset data base) is made to also be used at runtime, so if you did want to look into the graph framework we made for this package you could follow it. That said, you might want to look into just exposing the GraphAsset APIs (also look at how the GraphAssetProcessor is used) and use your own UI.

Wow, thank a lot for the pointer! I just had a try with Unity play studio (the WebGL app), and I am amazed by the “Muze Behavior” integration! This is exactly what I was thinking for our app before posting.

I’m curious of how @Darren_Kelly and Struckd made this possible. If you have anything you can share, do not hesitate :wink:

I understand all your points on why the API is internal. I’ll dig in the package and try to modify it in local to evaluate what’s possible to do :slight_smile:

haha oh no :smiley: did they call it Muze somewhere? I saw they called it Muse Behavior instead of Behavior, which I suppose is correct as they’re still using the old Muse package.

Yes, it’s in the app :laughing:

Oh ok, it’s “Muse” not “Muze”, that’s fine. Although I’ll ask them if they can update it to just call it Behavior :slight_smile:

Hi,

I am also interested in how this was done with Struckd. I’d like to modify the Behavior graph at runtime from outside the application. I’m not sure if serializing/deserializing the component would be the way to go.

Also, I’ve seen that an API is in development. Is there a planned release date for it?

Hi @SamKreModu

The Struckd team have a custom fork of the Behavior package that has been heavily modified for their needs.

Currently (and officially), the only way to “modify” a graph structure at runtime is the use of Run Subgraph Dynamically node:

This node dynamically assigns a subgraph using BlackboardVariable<Subgraph>. Unlike the static Run Subgraph node, this node doesn’t embed the subgraph into the current graph, as the assigned BlackboardVariable<Subgraph> can change at runtime. As a result, the subgraph’s Blackboard isn’t directly accessible. To work around this limitation, assign a Blackboard asset to act as an interface and enable data exchange between the current graph and the dynamically assigned subgraph at runtime.
Documentation