Search Unity

Question How to prevent dragging of edges and reconnecting of ports?

Discussion in 'UI Toolkit' started by Chris_Entropy, Aug 21, 2022.

  1. Chris_Entropy

    Chris_Entropy

    Joined:
    Apr 11, 2011
    Posts:
    202
    I am probably abusing the GraphView classes, but I want to do the following:
    I want to have a node connected to another node. When I create one node type, it should automatically connect to the other node type. This works so far.
    Now to the problem. The edge between their port should be fixed, so I don't want the user to be able to reconnect them, delete the edge by dragging and dropping it etc. The edge should be for all intents and purposes untouchable for the user. I can set the capabilities property of the edge, input node and output node to 0, but this only prevents me selecting the edge. I can still reconnect the ports and drag the edge, thus making it disappear.
    Any ideas how I can get the behaviour I want?
     
  2. julienkay

    julienkay

    Joined:
    Nov 12, 2013
    Posts:
    171
    Struggled with this as well and posting in case someone comes across this thread:

    After I created the edge using Port.ConnectTo I'm able to disable edge interaction via
    Code (CSharp):
    1. edge.SetEnabled(false);
    No idea why setting capabilities wouldn't work though.