void PaintWires() { Color color; float wireWidth; for (int i = 0; i < mGraph.Layers; i++) { uint layer = 1u << i; if ((mPaintLayers & layer) == 0) { continue; } for (int j = 0; j < mGraph.PathLength(i); j++) { int from, to; mGraph.PathAt(i, j, out from, out to); GraphNode fromNode = graph[from]; GraphNode toNode = graph[to]; for (int n = 0; n < fromNode.SocketCount; n++) { tmpSockA = fromNode.GetSocket(n); if (tmpSockA.layer != i) { continue; } if (!toNode.GetSocket(tmpSockA.toPort, ref tmpSockB)) { continue; } GetWireColorAndWidth(fromNode, tmpSockA, toNode, tmpSockB, out color, out wireWidth); DrawBezierWire(tmpSockA, tmpSockB, tmpSockA.GetSockPos(fromNode.ClipRect), tmpSockB.GetSockPos(toNode.ClipRect), color, wireWidth); } } } }
void PaintLinkNode() { if (mWireStart == null) { if (mShowNewNodePanel) { OnNewNodePanelGUIEnd(); } mShowNewNodePanel = false; return; } Vector2 p0, p1; float wireWidth; Color wireColor; if (mShowNewNodePanel) { p1 = mPanelPosition + mViewOffset; } else { p1 = Event.current.mousePosition; } p0 = mWireA.GetSockPos(mWireStart.ClipRect); GetWireColorAndWidth(mWireStart, mWireA, null, mWireB, out wireColor, out wireWidth); DrawBezierWire(mWireA, mWireB, p0, p1, wireColor, wireWidth); if ((!mShowNewNodePanel || !mPanelRect.Contains(Event.current.mousePosition)) && Event.current.button == 1 && Event.current.type == EventType.MouseUp) { mWireStart = null; return; } bool click = Event.current.button == 0 && Event.current.type == EventType.MouseUp; if (!mShowNewNodePanel && click) { if (mRaycastNode == null) { mShowNewNodePanel = true; mPanelPosition = Event.current.mousePosition - mViewOffset; } else if (TryConnectNode(mWireLayer, mWireA, mWireB, mWireStart, mRaycastNode)) { mWireStart = null; } } else if (mShowNewNodePanel) { mShowNewNodePanel = OnNewNodePanelGUI(mPanelPosition + mViewOffset, ref mPanelRect); if (!mShowNewNodePanel) { mWireStart = null; OnNewNodePanelGUIEnd(); } } }
protected virtual void OnSocketGUI(GraphViewEditorWindow window, NodeSocket sock) { Rect rect = new Rect(); rect.size = new Vector2(PixelSize.x - 40, 15); rect.center = sock.GetSockPos(ClipRect) + Vector2.up * 8 * (sock.uvCoord.y == 0 ? 1 : -1); if (window.mShowContextMenu) { GUI.Label(rect, "", "Icon.ClipSelected"); } else if (GUI.Button(rect, "", "Icon.ClipSelected")) { window.CreateConnection(this, sock.layer, sock.sockPort, sock.toPort); } }