void DraggedLinkOverAnchorCallback(Anchor anchor) { if (!AnchorUtils.AnchorAreAssignable(editorEvents.startedLinkAnchor, anchor)) { return; } //update anchor highlight if (anchor.anchorType == AnchorType.Input) { if (anchor.linkCount >= 1) { //highlight links with delete color foreach (var link in anchor.links) { link.highlight = LinkHighlightMode.Delete; } anchor.highlighMode = AnchorHighlight.AttachReplace; } else { anchor.highlighMode = AnchorHighlight.AttachNew; } } else { //highlight our link with delete color foreach (var link in editorEvents.startedLinkAnchor.links) { link.highlight = LinkHighlightMode.Delete; } if (anchor.linkCount > 0) { anchor.highlighMode = AnchorHighlight.AttachAdd; } else { anchor.highlighMode = AnchorHighlight.AttachNew; } } }
void DrawNodeCurve(Anchor anchor, Vector2 endPoint, bool anchorSnapping = true) { Rect anchorRect = anchor.rectInGraph; Vector3 startPos = new Vector3(anchorRect.x + anchorRect.width, anchorRect.y + anchorRect.height / 2, 0); Vector3 startDir = Vector3.right; if (anchorSnapping && editorEvents.isMouseOverAnchor) { var toAnchor = editorEvents.mouseOverAnchor; var fromAnchor = editorEvents.startedLinkAnchor; if (AnchorUtils.AnchorAreAssignable(fromAnchor, toAnchor)) { endPoint = toAnchor.rectInGraph.center; } } float tanPower = (startPos - (Vector3)endPoint).magnitude / 2; tanPower = Mathf.Clamp(tanPower, 0, 100); DrawSelectedBezier(startPos, endPoint, startPos + startDir * tanPower, (Vector3)endPoint + -startDir * tanPower, anchor.colorSchemeName, 4, LinkHighlightMode.None); }