Exemplo n.º 1
0
        void DraggedLinkOverAnchorCallback(PWAnchor anchor)
        {
            if (!PWAnchorUtils.AnchorAreAssignable(editorEvents.startedLinkAnchor, anchor))
            {
                return;
            }

            //update anchor highlight
            if (anchor.anchorType == PWAnchorType.Input)
            {
                if (anchor.linkCount >= 1)
                {
                    //highlight links with delete color
                    foreach (var link in anchor.links)
                    {
                        link.highlight = PWLinkHighlight.Delete;
                    }
                    anchor.highlighMode = PWAnchorHighlight.AttachReplace;
                }
                else
                {
                    anchor.highlighMode = PWAnchorHighlight.AttachNew;
                }
            }
            else
            {
                //highlight our link with delete color
                foreach (var link in editorEvents.startedLinkAnchor.links)
                {
                    link.highlight = PWLinkHighlight.Delete;
                }

                if (anchor.linkCount > 0)
                {
                    anchor.highlighMode = PWAnchorHighlight.AttachAdd;
                }
                else
                {
                    anchor.highlighMode = PWAnchorHighlight.AttachNew;
                }
            }
        }
Exemplo n.º 2
0
    void DrawNodeCurve(PWAnchor 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 (PWAnchorUtils.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, PWLinkHighlight.None);
    }