Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Working example #2

Open
TermWay opened this issue Sep 23, 2023 · 0 comments
Open

Working example #2

TermWay opened this issue Sep 23, 2023 · 0 comments

Comments

@TermWay
Copy link

TermWay commented Sep 23, 2023

Hello Eric,

I tried to use this package, but I am having problems figuring out how to use it.

First, there were compilation errors in your Testing example. I had to change the access modifiers for most of the override methods from "protected" to "protected internal" and comment out the "OnNodeMoved" method.

Here's the corrected code:

using UnityEngine;
using UnityEngine.UIElements;

namespace GraphViewPlayer
{
    public class Testing : GraphView
    {
        protected internal override void ExecuteCopy() { Debug.Log("OnCopy"); }

        protected internal  override void ExecuteCut() { Debug.Log("OnCut"); }

        protected internal override void ExecutePaste() { Debug.Log("OnPaste"); }

        protected internal override void ExecuteDuplicate() { Debug.Log("OnDuplicate"); }

        protected internal override void ExecuteDelete() { Debug.Log("OnDelete"); }

        protected internal override void ExecuteUndo() { Debug.Log("OnUndo"); }

        protected internal override void ExecuteRedo() { Debug.Log("OnRedo"); }

        protected internal override void ExecuteEdgeCreate(BaseEdge edge)
        {
            Debug.Log("Edge created");
            AddElement(edge);
        }

        protected internal override void ExecuteEdgeDelete(BaseEdge edge)
        {
            Debug.Log("Edge deleted");
            RemoveElement(edge);
        }

       //protected internal override void OnNodeMoved(BaseNode element) { }

        protected internal override void OnViewportChanged() { }

        public new class UxmlFactory : UxmlFactory<Testing, UxmlTraits>
        {
        }
    }
}

I was able to create a UIDocument (and an EditorWindow) with the graph view and the zoom feature working. However, I am unsure about how to add nodes with connections, similar to what is shown in your screenshot. Should I utilize the BaseNode class and add them manually to the GraphView?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant