Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

How to make a simple node editor using UI Elements?

Discussion in 'UIElements' started by Cumuka, Sep 27, 2019.

  1. Cumuka

    Cumuka

    Joined:
    Nov 27, 2014
    Posts:
    17
    Hi,

    I've been trying to learn how to make a node editor tool in unity but I'd like to try it in UI Elements. I think
    GUILayout.Window
    is a pretty good solution and drag feature comes out of the box. There is a good sample here:
    https://docs.unity3d.com/ScriptReference/EditorWindow.BeginWindows.html

    UI Elements do have a similar feature in examples in github repo. I noticed that in this sample have a similar window element but it fills in its container. I couldn't find any solution to make similar behavior like
    GUILayout.Window
    .

    Also, I've tried to dig in this repo for graph editor like node editor. But it's beyond complicated and huge project.

    Thanks in advance!
     
  2. uDamian

    uDamian

    Unity Technologies

    Joined:
    Dec 11, 2017
    Posts:
    289
    The end of this short video on UIElements shows a bit on how to make a draggable, floating, element. But I'd suggest watching the entire video if you're new to UIElements.


    And for completeness, there is a node-based system implemented in UIElements already. It's called GraphView and it's what products like ShaderGraph and Visual Effects Graph use. However, we don't officially support the GraphView API so there's not a lot of documentation. It's also overkill for most applications. Using the video above and if you search for GraphView.Edge in the codebase to see how the edges are drawn, you should have something basic to start with.
     
  3. taylank

    taylank

    Joined:
    Nov 3, 2012
    Posts:
    111