예제 #1
0
        private void OnPlugClicked(Node node, Plug plug)
        {
            if (plug.type == Plug.PlugType.In && outPlug != null)
            {
                if (node == outNode)
                {
                    Debug.Log("Cannot connect plugs of the same node");
                    ClearPlugSelection();
                    return;
                }
                Undo.RecordObject(this, "add connection");
                PlugConnection newConnection = new PlugConnection(
                    nodes.IndexOf(outNode),
                    outNode.OutPlugs.IndexOf(outPlug),
                    nodes.IndexOf(node),
                    node.InPlugs.IndexOf(plug)
                    );

                if (connections.Contains(newConnection))
                {
                    Debug.Log("Connection already exists");
                }
                else
                {
                    connections.Add(newConnection);
                    outPlug.connected = true;
                    plug.connected    = true;
                }

                ClearPlugSelection();
            }
            else if (plug.type == Plug.PlugType.Out)
            {
                outNode = node;
                outPlug = plug;
            }
        }
예제 #2
0
 private void OnEnable()
 {
     outNode   = null;
     outPlug   = null;
     hideFlags = HideFlags.None;
 }
예제 #3
0
 public void UpdateVertices(Plug outPlug, Plug inPlug)
 {
     outPos = outPlug.PlugCenter();
     inPos  = inPlug.PlugCenter();
 }
예제 #4
0
 public void ClearPlugSelection()
 {
     outNode = null;
     outPlug = null;
 }