I previously sent this to Unity’s support email address, but was told I should post it here instead.
I’m currently taking a look at implementing a tool using the public but undocumented GraphGUI. I understand that I could write my own GUI tools or use something 3rd party, but if at all possible I’d rather keep things consistent with what’s already in Unity and avoid additional dependencies.
I’ve managed to create a graph and get it drawing. I’ve hit three things which I haven’t yet solved, which I thought it certainly can’t hurt to ask about. It would be amazing if you could please help me out with any of the following:
-
How do I set the size of a Node in the graph? I can set width and height in the position when I create the Node, but this seems to then get overwritten. If I set a width and height by overriding GraphGUI.NodeGUI(…) it works intermittently.
-
How do I detect clicks on Nodes? At this stage I am assuming that in an overridden GraphGUI.NodeGUI(…) I can examine Event.current, but haven’t been able to test this because my Nodes keep reverting to an unclickable default size width.
-
How can I make and use a custom GUIStyle for a Node? I’ve found Styles.GetNodeStyle(…), which I assume is that the “style” string on a Node is used for, but I haven’t found how to add a new style.
Edit, in case someone from Unity sees this: The UnityEditor.Graphs namespace is completely undocumented despite being exposed. Is this because we’re not meant to be using it, or is it because nobody’s got around to documenting it yet? (Given the number of workflows and tools that benefit from this kind of UI it’d be awesome if the built-in one was available for use, rather than everyone and their dogs writing their own or bringing in 3rd party dependencies.)