protected virtual void ApplyConnect() { if (currentNode != null) { CustomEditorHelper.DrawConnection(currentNode.BezierStartPosition, Event.current.mousePosition); if (Event.current.type != EventType.MouseDown) { return; } switch (Event.current.button) { case 0: var isConnected = false; foreach (var node in nodes) { if (!node.FullRect.Contains(Event.current.mousePosition)) { continue; } currentNode.CurrentJointPoint.Connect(node); isConnected = true; break; } if (!isConnected) { currentNode.CurrentJointPoint.Connect(null); } CurrentState = WindowState.None; break; case 1: CurrentState = WindowState.ContextMenu; break; } } else { CurrentState = WindowState.None; } }
public virtual void DrawConnections() { foreach (var child in Children) { //Debug.Log(string.Format("Length of {0}'s joints:{1}", child.ElementName, child.joints.Count)); foreach (var point in child.joints) { if (point.TargetId == NothingId) { continue; } var startPoint = Position + child.Position + point.Offset + new Vector2(0, Size.y); var destinationNode = point.Target.Parent; if (destinationNode == null) { continue; } var endPoint = point.Target.Parent.Position + destinationNode.joints [0].Offset; CustomEditorHelper.DrawConnection(startPoint, endPoint); } } }