Exemplo n.º 1
0
        //The actual connection graphic
        void DrawConnection(Vector2 fromPos, Vector2 toPos)
        {
            color = isActive ? color : Colors.Grey(0.3f);
            if (!Application.isPlaying)
            {
                color = isActive ? defaultColor : Colors.Grey(0.3f);
                var highlight = GraphEditorUtility.activeElement == this || GraphEditorUtility.activeElement == sourceNode || GraphEditorUtility.activeElement == targetNode;
                if (startRect.Contains(Event.current.mousePosition) || endRect.Contains(Event.current.mousePosition))
                {
                    highlight = true;
                }
                color.a = highlight ? 1 : color.a;
                size    = highlight ? defaultSize + 2 : defaultSize;
            }

            //alter from/to if active relinking
            if (isRelinkingActive)
            {
                if (relinkState == RelinkState.Source)
                {
                    fromPos = Event.current.mousePosition;
                }
                if (relinkState == RelinkState.Target)
                {
                    toPos = Event.current.mousePosition;
                }
                ParadoxNotion.CurveUtils.ResolveTangents(fromPos, toPos, Prefs.connectionsMLT, direction, out fromTangent, out toTangent);
                size = defaultSize;
            }

            var shadow = new Vector2(3.5f, 3.5f);

            Handles.DrawBezier(fromPos, toPos + shadow, fromPos + shadow + fromTangent + shadow, toPos + shadow + toTangent, Color.black.WithAlpha(0.1f), StyleSheet.bezierTexture, size + 10f);
            Handles.DrawBezier(fromPos, toPos, fromPos + fromTangent, toPos + toTangent, color, StyleSheet.bezierTexture, size);

            GUI.color = color.WithAlpha(1);
            if (tipConnectionStyle == TipConnectionStyle.Arrow)
            {
                GUI.DrawTexture(endRect, StyleSheet.GetDirectionArrow(toTangent.normalized));
            }
            if (tipConnectionStyle == TipConnectionStyle.Circle)
            {
                GUI.DrawTexture(endRect, StyleSheet.circle);
            }
            GUI.color = Color.white;
        }