GraphView - How can I drag an object out of an object field?

I’m building a custom GraphView for AI in my RTS, and I’m looking for a solution to drag elements OUT of the graph view. I can drag Scriptable Objects into fields on the nodes of the graph view, but I cannot drag them back out to put into parameters of other objects. Example:

8385381--1106016--upload_2022-8-23_21-3-41.png

The key issue, is that while the graphview can reference ScriptableObjects that are saved as files, I’m planning on it producing ScriptableObjects that are not associated with files. See this code:

        soField = new ObjectField
        {
            objectType = typeof(BooleanObservable),
            name = "b2",
            value = new BooleanObservable()
            {
                name = "Boolean Test",
                Value = true
            },
        };

        soField.RegisterValueChangedCallback(v =>
        {
            node.BooleanObservable = soField.value as BooleanObservable;
        });

        node.mainContainer.Add(soField);

As you can see, when it sets up the field (line 5), Value = new BooleanObservable()… it is generating that scriptable object in memory only, and not saving it to a file. I’m hoping for a way to reference that in a different selected game object. (as shown in the picture)

Any ideas if it is possible, or even alternative approaches?

As graph view and the graph tools foundation are UI toolkit based, questions like these are probably better suited to the UI Toolkit subforum.

Nonetheless, there’s a page in the documentation about supporting drag and drop: Unity - Manual: Supporting drag and drop

Also worth noting that Graph View isn’t being developed in place of Graph Tools Foundation. I would be wary about developing too heavily into it.

1 Like

Thank you, that was enlightening: “Graph View isn’t being developed” I had been wanting to work with GraphView, and hadn’t even realized that there was another Graph thing to look for. I really wish the latest package somehow clarified this. I’m heading over to the new one. Thank you! (Please note, I didn’t take your word alone for it, but went to research this first. And everything I saw backed this up, so thank you.)

No longer looking for an answer for this here.

You’re a smart man for thinking like this.

And yeah I was a little bummed to find out the same thing. I’m holding off on Graph tools foundation until it and UI toolkit are better developed… and when I’m also better with in general.