public void OnGui(Event current, ZoomWindow zoomer) { if (script == null) { return; } if (refreshConnections == null) { throw new System.Exception("Graph in invalid state. Should have called Initialize()."); } if (refreshConnections.Count > 0) { foreach (var cp in refreshConnections) { foreach (var connGUID in cp.connection.connectedToGUIDs) { try { var otherCP = connectionPoints[connGUID]; otherCP.ConnectTo(cp); cp.ConnectTo(otherCP); } catch (System.Exception) { Debug.Log("Could not find GUID " + connGUID); } } } refreshConnections.Clear(); } Vector2 zoomerOffset = zoomer.GetContentOffset(); save = false; warnings.Clear(); inputNode.Offset(zoomerOffset); if (inputNode.ProcessEvents(current)) { save = true; } inputNode.CheckForErrors(warnings); inputNode.DrawConnectionWires(); outputNode.Offset(zoomerOffset); if (outputNode.ProcessEvents(current)) { save = true; } outputNode.CheckForErrors(warnings); foreach (var node in branchEntityDatas) { node.Offset(zoomerOffset); if (node.ProcessEvents(current)) { save = true; } node.CheckForErrors(warnings); // draw connections node.DrawConnectionWires(); } inputNode.OnGUI(); outputNode.OnGUI(); foreach (var node in branchEntityDatas) { node.OnGUI(); } zoomer.DisplayMessage(warnings.Count > 0, warnings); if (startConnection != null) { // we want to draw the line on-top of everything else startConnection.DrawConnectionTo(current.mousePosition); GUI.changed = true; if (current.button == 1 && current.type == EventType.MouseDown) { startConnection.isCreatingNewConnection = false; startConnection = null; endConnection = null; } else if (endConnection != null) { CompleteConnection(); } else if (current.button == 0 && current.type == EventType.MouseUp) { // if this has not been consumed we can assume that // the mouse was not released over a connection point or a GraphEntity. // check if the mouse was released over an entity. // if so, && it's a valid entity (ie output is not on same entity as input), // open context menu to add new input/output // if not && the connection type is ControlFlow, open context menu to make new branch savedMousePos = current.mousePosition + zoomerOffset; if (startConnection.connection.type == ConnectionType.ControlFlow) { CreateStandAloneContextMenu(startConnection); } startConnection.isCreatingNewConnection = false; startConnection = null; } } else if (current.button == 1 && current.type == EventType.MouseUp && !zoomer.isScreenMoved) { // open context menu to make new branch savedMousePos = current.mousePosition + zoomerOffset; CreateStandAloneContextMenu(); } else { zoomer.UpdateWithCurrentZoomerSettings(zoomerSettings); } if (save) { // temp save. Do not save to json file. save = false; } }