public static void DrawGraphNodeGizmo(GraphNode node, GizmoType type) { using (new GizmosColor(GraphEditorWindow.GetGraphColor(node.graph))) { if (node.graph == null) { Vector3 nodePinPosition = node.transform.position + GraphEditorWindow.GetGraphNodePinShift(node); Gizmos.DrawLine(node.transform.position, nodePinPosition); Gizmos.DrawWireSphere(nodePinPosition, GraphEditorWindow.GraphNodePinRadius * 1.1f); return; } if ((type & GizmoType.Selected) != 0) { GraphEditor.DrawGraphGizmo(node.graph, GizmoType.NonSelected); Vector3 pinShift = GraphEditorWindow.GetGraphNodePinShift(node); Vector3 nodePinPosition = node.transform.position + pinShift; Gizmos.DrawLine(node.transform.position, nodePinPosition); Gizmos.DrawWireSphere(nodePinPosition, GraphEditorWindow.GraphNodePinRadius * 1.1f); foreach (GraphNode linkedNode in node.EnumLinkedNodes()) { Gizmos.DrawLine(nodePinPosition, linkedNode.transform.position + pinShift); } } else if (type == GizmoType.NonSelected) { Vector3 pinShift = GraphEditorWindow.GetGraphNodePinShift(node); Vector3 nodePinPosition = node.transform.position + pinShift; Gizmos.DrawLine(node.transform.position, nodePinPosition); Gizmos.DrawSphere(nodePinPosition, GraphEditorWindow.GraphNodePinRadius); } } }
public static void DrawGraphGizmo(Graph graph, GizmoType type) { Color graphColor = GraphEditorWindow.GetGraphColor(graph); using (new GizmosColor(graphColor)) { foreach (GraphNode node in graph.Nodes) { GraphNodeEditor.DrawGraphNodeGizmo(node, GizmoType.NonSelected); } Color linkColor = Color.gray; if ((type & GizmoType.Selected) != 0) { linkColor = graphColor * 0.75f; } else if ((type & GizmoType.NonSelected) != 0) { linkColor = graphColor * 0.25f; } using (new GizmosColor(linkColor)) { foreach (var links in graph.Links) { GraphNode nodeFrom = links.Key; foreach (GraphNode nodeTo in links.Value) { Vector3 pinShift = GraphEditorWindow.GetGraphNodePinShift(nodeTo); Gizmos.DrawLine(nodeFrom.transform.position + pinShift, nodeTo.transform.position + pinShift); } } } } }
public void OnSceneGUI() { if (selectedAddLinkObjectFrom != null && selectedAddLinkObjectTo != null) { Vector3 pinShift = GraphEditorWindow.GetGraphNodePinShift(selectedAddLinkObjectFrom); Handles.DrawLine(selectedAddLinkObjectFrom.transform.position + pinShift, selectedAddLinkObjectTo.transform.position + pinShift); } }