I wondered if anyone has had any experience with the GraphView Get…ByGuid methods, I’ve played around with the GetNodeByGuid method and can’t figure out where the GUID is generated. Node does not have that property, is it expecting a user generated System.GUID in a derived class or UnityEditor.GUID base on a ScriptableObject, or is it a GUID generated by GraphView when it Adds a GraphElement.
Documentation is less than forthcoming (I know, experimental) and I’ve spent a frustrating afternoon trying to figure it out.
Thanks for any help.
When you create a Node or any VisualElement it will have a viewDataKey property which is used by the editor for various reasons. In a GraphView it is where the guid should stored for each node. Using Get…ByGuid method, it looks at the viewDataKey for that information. It should be stored in the data that the node is displaying, you then have to set that viewDataKey to the guid of the data the node is representing.
Here is a video(not mine) for a tutorial on Behavior Trees and it is also a great tutorial for setting up a GraphView to help visually create the Behaviour Tree. It’s long, has two parts and might have some bugs depending on the Unity version you are using, you’ve been warned.
Thanks for the reply Chris, the viewDataKey is what I ended up using to store a string GUID but hadn’t tried using it with the GetByGUID methods. I’ll give it a try. Doesn’t seem very intuitive, like a lot of things in GraphView. :). I see they’re developing a new version .