Customise rendering of Task node in graph editor

Valentin C

New member
Hello!

I would like to customise how the tasks look inside the graph editor. To be more precise, I am interested in:
  1. The little icons that can be drawn on the nodes (interruption, breakpoint, linked task, error because of the rename of the class)
  2. Changing the color of the node (but could be done by having a colored circle drawn over the node like the icon)
  3. Potentially drawing a (colored) line between two linked tasks

I saw we can customise how a field looks in the task's inspector using the ObjectDrawer (doc) but I didn't see a way to customise a node. The ObjectDrawer class gives access to the Task the variable will "belong to", which gives access to the NodeData class. In this class, we have access to some interesting fields including the Icon field or ColorIndex fields but I am not confident in "hacking" those fields to serve my goal, and having a dedicated variable in every task does not sound nice.

It would be nice to have a "custom editor" for the Task similar to Unity's CustomEditor (while keeping the ObjectDrawer which is the equivalent of Unity's PropertyDrawer)

I know Opsive is working on a v2 of the Behavior Designer, maybe this kind of feature will be supported?

Thanks in advance, keep the good work up!

TaskError.png
 
Last edited:
The little icons that can be drawn on the nodes (interruption, breakpoint, linked task, error because of the rename of the class)
You can change the task icon with the TaskIcon attribute, but the other icons are built in. I haven't gotten any requests to make those icons customizable but how were you thinking of specifying which icon to use?

Changing the color of the node (but could be done by having a colored circle drawn over the node like the icon)
Each task has an EditorData struct that determines the editor-related properties - one of those is the color index which you can change programmatically. These nodes are not drawn procedurally though so you can't change them outside of the colors already created.

Potentially drawing a (colored) line between two linked tasks
The drawing of this line uses the GL.Line function so right now that isn't supported. I'm curious though in what areas you are wanting a dotted versus solid line.

I know Opsive is working on a v2 of the Behavior Designer, maybe this kind of feature will be supported?
I will keep this use can in mind for v2. V2 uses Unity's UIElements so things are a bit different but there is already more customization. The watched fields can now be edited within the node, and multiple actions/conditions can be stacked. This is still very much a work in progress and a lot of the hold up right now is for the DOTS framework to stabilize, but it's getting there.

1621967752187.png
 
Hello Justin, thanks for your quick response!

You can change the task icon with the TaskIcon attribute, but the other icons are built in. I haven't gotten any requests to make those icons customizable but how were you thinking of specifying which icon to use?
My main goal is to display the error icon whenever I want to grab the attention of the user whenever something goes wrong (SharedVariable not set / LinkedTask not set / incorrect variable value / ...). I would also love to display additional icons under certain circumstances (SharedVariable with a specific value for instance. integer is positive? Display a custom "+" icon. integer is negative? Display a custom "-" icon. integer is equal to 0? Display a custom "0" icon)

Each task has an EditorData struct that determines the editor-related properties - one of those is the color index which you can change programmatically. These nodes are not drawn procedurally though so you can't change them outside of the colors already created.
Yes, that's what I saw, I'll give it a try and see if it can accomodate my needs, but I still need to use an ObjectDrawer to access this struct, don't I?

The drawing of this line uses the GL.Line function so right now that isn't supported. I'm curious though in what areas you are wanting a dotted versus solid line.
I don't need a dotted line, I would like to draw a line between a task A that references task B to see at a glance there is a connection (and if not, add an error icon on task A for instance). This may clutter the behavior designer, but I should not need to draw a lot of them in the end.

I will keep this use can in mind for v2. V2 uses Unity's UIElements so things are a bit different but there is already more customization. The watched fields can now be edited within the node, and multiple actions/conditions can be stacked. This is still very much a work in progress and a lot of the hold up right now is for the DOTS framework to stabilize, but it's getting there.

View attachment 5950
Exciting news! Thanks for the update Justin!
 
My main goal is to display the error icon whenever I want to grab the attention of the user whenever something goes wrong (SharedVariable not set / LinkedTask not set / incorrect variable value / ...). I would also love to display additional icons under certain circumstances (SharedVariable with a specific value for instance. integer is positive? Display a custom "+" icon. integer is negative? Display a custom "-" icon. integer is equal to 0? Display a custom "0" icon)
Thanks, I understand your use cases better. I'll see if I can add a way to make it more flexible to do custom drawing on the actual node.

Yes, that's what I saw, I'll give it a try and see if it can accomodate my needs, but I still need to use an ObjectDrawer to access this struct, don't I?
No ObjectDrawer needed for that case, you can do it in any editor/task script. As long as you have a reference to the task you can access it.
 
I was doing some research along the same lines as @Valentin C.
In my case the motivation was to introduce some custom validation of shared fields in the Node Editor to easily fill the gaps in BehaviorDesigner functionality. For example, currently the user can miss binding shared fields, and no warning is given.
And to give a visual warning if the validation fails.
 
What would be your ideal scenario for this type of callback? An event that you can subscribe to when a node is drawn?
 
What would be your ideal scenario for this type of callback? An event that you can subscribe to when a node is drawn?
Currently there is already a method available: Task.OnDrawNodeText - its seems the most logical point to add any piece of custom node drawing code. Or another method with similar signature like Task.OnDrawNode where the developer can use GUI or GUILayout methods.
 
+1 on this feature request. It would be nice, if I could assign a color to each node, similarly to xNode. In xNode you can just use class atribute, like [NodeTint("#a76132")].
 
Top