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; } }
private void OnEnable() { outNode = null; outPlug = null; hideFlags = HideFlags.None; }
public void UpdateVertices(Plug outPlug, Plug inPlug) { outPos = outPlug.PlugCenter(); inPos = inPlug.PlugCenter(); }
public void ClearPlugSelection() { outNode = null; outPlug = null; }