Search Unity

Callback when releasing and edge at an empty point

Discussion in 'UI Toolkit' started by tnyLe, Apr 4, 2020.

  1. tnyLe

    tnyLe

    Joined:
    Dec 19, 2018
    Posts:
    8
    Hi I’m trying to make a little dialogue editor for my game.

    Just wondering if there’s an event I can tap into when you have released a ghost edge after dragging it out from a node’s port.

    I would like to be able to create a node simply by dragging out a edge from a port onto an empty part of the graph, maybe have a menu pop up to be able to create different node types etc. Right now I’m just using a button, which is a bit slow and I can only make it appear at a single location on the graph.

    Cheers
     
  2. antoine-unity

    antoine-unity

    Unity Technologies

    Joined:
    Sep 10, 2015
    Posts:
    780
    Have you tried adding a callback to the GraphView instance
    nodeCreationRequest
    callback? This should be called even when dragging an edge into an empty space.
     
  3. tnyLe

    tnyLe

    Joined:
    Dec 19, 2018
    Posts:
    8
    Just tried it... doesn't seem to do anything:

    activeConversation = new ConversationGraphView
    {
    name = conversationName,
    };
    activeConversation.nodeCreationRequest = x =>
    { Debug.Log($"Node creation request> index: {x.index}, mpos: {x.screenMousePosition}, target: {x.target}"); };

    Nothing prints or happens when I drag out and edge from a port or create a port conventionally with the button... o_O