public void Delete() { ConnectionGUIUtility.FireNodeEvent(new OnConnectionEvent(OnConnectionEvent.EventType.EVENT_CONNECTION_DELETED, this)); }
/** * throughputListDict contains: * group/ * throughput assets */ public void DrawConnection(List <NodeGUI> nodes, Dictionary <string, List <DepreacatedThroughputAsset> > throughputListDict) { var startNodes = nodes.Where(node => node.nodeId == outputNodeId).ToList(); if (!startNodes.Any()) { return; } var startPoint = startNodes[0].GlobalConnectionPointPosition(outputPoint.pointId); startPoint = NodeGUI.ScaleEffect(startPoint); var startV3 = new Vector3(startPoint.x, startPoint.y, 0f); var endNodes = nodes.Where(node => node.nodeId == inputNodeId).ToList(); if (!endNodes.Any()) { return; } var endPoint = endNodes[0].GlobalConnectionPointPosition(inputPoint.pointId); endPoint = NodeGUI.ScaleEffect(endPoint); var endV3 = new Vector3(endPoint.x, endPoint.y + 1f, 0f); var centerPoint = startPoint + ((endPoint - startPoint) / 2); var centerPointV3 = new Vector3(centerPoint.x, centerPoint.y, 0f); var pointDistance = (endPoint.x - startPoint.x) / 3f; if (pointDistance < AssetBundleGraphGUISettings.CONNECTION_CURVE_LENGTH) { pointDistance = AssetBundleGraphGUISettings.CONNECTION_CURVE_LENGTH; } var startTan = new Vector3(startPoint.x + pointDistance, startPoint.y, 0f); var endTan = new Vector3(endPoint.x - pointDistance, endPoint.y, 0f); Handles.DrawBezier(startV3, endV3, startTan, endTan, Color.gray, null, 4f); // draw connection label if connection's label is not normal. if (NodeGUI.scaleFactor == NodeGUI.SCALE_MAX) { switch (label) { case AssetBundleGraphSettings.DEFAULT_OUTPUTPOINT_LABEL: { // show nothing break; } case AssetBundleGraphSettings.BUNDLIZER_BUNDLE_OUTPUTPOINT_LABEL: { var labelPointV3 = new Vector3(centerPointV3.x - ((AssetBundleGraphSettings.BUNDLIZER_BUNDLE_OUTPUTPOINT_LABEL.Length * 6f) / 2), centerPointV3.y - 24f, 0f); Handles.Label(labelPointV3, AssetBundleGraphSettings.BUNDLIZER_BUNDLE_OUTPUTPOINT_LABEL); break; } default: { var labelPointV3 = new Vector3(centerPointV3.x - ((label.Length * 7f) / 2), centerPointV3.y - 24f, 0f); Handles.Label(labelPointV3, label); break; } } } // draw connection arrow. if (NodeGUI.scaleFactor == NodeGUI.SCALE_MAX) { GUI.DrawTexture( new Rect( endV3.x - AssetBundleGraphGUISettings.CONNECTION_ARROW_WIDTH + 4f, endV3.y - (AssetBundleGraphGUISettings.CONNECTION_ARROW_HEIGHT / 2f) - 1f, AssetBundleGraphGUISettings.CONNECTION_ARROW_WIDTH, AssetBundleGraphGUISettings.CONNECTION_ARROW_HEIGHT ), ConnectionGUIUtility.connectionArrowTex ); } /* * draw throughtput badge. */ var throughputCount = 0; foreach (var list in throughputListDict.Values) { throughputCount += list.Count; } var offsetSize = throughputCount.ToString().Length * 20f; buttonRect = new Rect(centerPointV3.x - offsetSize / 2f, centerPointV3.y - 7f, offsetSize, 20f); if ( Event.current.type == EventType.ContextClick || (Event.current.type == EventType.MouseUp && Event.current.button == 1) ) { var rightClickPos = Event.current.mousePosition; if (buttonRect.Contains(rightClickPos)) { var menu = new GenericMenu(); menu.AddItem( new GUIContent("Delete"), false, () => { Delete(); } ); menu.ShowAsContext(); Event.current.Use(); } } if (GUI.Button(buttonRect, throughputCount.ToString(), connectionButtonStyle)) { conInsp.UpdateCon(this, throughputListDict); ConnectionGUIUtility.FireNodeEvent(new OnConnectionEvent(OnConnectionEvent.EventType.EVENT_CONNECTION_TAPPED, this)); } }