public void DrawConnections(EditableConnection currentlySelected) { Vector2 start = Vector2.zero; Vector2 end = Vector2.zero; float xPos = 0; float yPos = 0; for (int i = 0; i < Info.Connections.Count; i++) { bool connectingToOption = false; if (Info.Connections[i].ConnectionType == EditableConnection.eConnectiontype.Speech) { EditableSpeechConnection connection = Info.Connections[i] as EditableSpeechConnection; DialogueEditorUtil.GetConnectionDrawInfo(rect, connection.Speech, out start, out end); xPos = connection.Speech.EditorInfo.xPos; yPos = connection.Speech.EditorInfo.yPos; } else if (Info.Connections[i].ConnectionType == EditableConnection.eConnectiontype.Option) { EditableOptionConnection connection = Info.Connections[i] as EditableOptionConnection; DialogueEditorUtil.GetConnectionDrawInfo(rect, connection.Option, out start, out end); xPos = connection.Option.EditorInfo.xPos; yPos = connection.Option.EditorInfo.yPos; connectingToOption = true; } bool selected = (currentlySelected != null && currentlySelected == Info.Connections[i]); Vector2 toStart = (start - end).normalized; Vector2 toEnd = (end - start).normalized; if (selected) { Handles.DrawBezier(start, end, start + toStart, end + toEnd, SelectedColor, null, LINE_WIDTH * 3); } Handles.DrawBezier(start, end, start + toStart, end + toEnd, DefaultColor, null, LINE_WIDTH); Vector2 intersection; Vector2 boxPos = new Vector2(xPos, yPos); if (DialogueEditorUtil.DoesLineIntersectWithBox(start, end, boxPos, connectingToOption, out intersection)) { if (selected) { DialogueEditorUtil.DrawArrowTip(intersection, toEnd, SelectedColor, LINE_WIDTH * 3); } DialogueEditorUtil.DrawArrowTip(intersection, toEnd, DefaultColor); } } }
public override void DrawConnections() { if (OptionNode.Speech != null) { Vector2 start, end; DialogueEditorUtil.GetConnectionDrawInfo(rect, OptionNode.Speech, out start, out end); Vector2 toStart = (start - end).normalized; Vector2 toEnd = (end - start).normalized; Handles.DrawBezier(start, end, start + toStart, end + toEnd, DefaultColor, null, LINE_WIDTH); Vector2 intersection; Vector2 boxPos = new Vector2(OptionNode.Speech.EditorInfo.xPos, OptionNode.Speech.EditorInfo.yPos); if (DialogueEditorUtil.DoesLineIntersectWithBox(start, end, boxPos, false, out intersection)) { DialogueEditorUtil.DrawArrowTip(intersection, toEnd, DefaultColor); } } }