Inheritance: IEdgeGUI
コード例 #1
0
 public void DoDraggedEdge()
 {
     if (EdgeGUI.s_DragSourceSlot != null)
     {
         EventType typeForControl = Event.current.GetTypeForControl(0);
         if (typeForControl != EventType.MouseDrag)
         {
             if (typeForControl == EventType.Repaint)
             {
                 Rect    position = EdgeGUI.s_DragSourceSlot.m_Position;
                 Vector2 end      = Event.current.mousePosition;
                 if (EdgeGUI.s_DropTarget != null)
                 {
                     Rect position2 = EdgeGUI.s_DropTarget.m_Position;
                     end = GUIClip.Clip(new Vector2(position2.x, position2.y + 9f));
                 }
                 EdgeGUI.DrawEdge(GUIClip.Clip(new Vector2(position.xMax, position.y + 9f)), end, (Texture2D)Styles.selectedConnectionTexture.image, Color.white, this.edgeStyle);
             }
         }
         else
         {
             EdgeGUI.s_DropTarget = null;
             this.dontDrawEdge    = null;
             Event.current.Use();
         }
     }
 }
コード例 #2
0
        private static void DrawEdge(Edge e, Texture2D tex, Color color, EdgeGUI.EdgeStyle style)
        {
            Vector2 start;
            Vector2 end;

            EdgeGUI.GetEdgeEndPoints(e, out start, out end);
            EdgeGUI.DrawEdge(start, end, tex, color, style);
        }
コード例 #3
0
        public void DoEdges()
        {
            int num  = 0;
            int num2 = 0;

            if (Event.current.type == EventType.Repaint)
            {
                foreach (Edge current in this.host.graph.edges)
                {
                    if (current != this.dontDrawEdge && current != this.moveEdge)
                    {
                        Texture2D tex = (Texture2D)Styles.connectionTexture.image;
                        if (num < this.edgeSelection.Count && this.edgeSelection[num] == num2)
                        {
                            num++;
                            tex = (Texture2D)Styles.selectedConnectionTexture.image;
                        }
                        Color color = (!current.toSlot.isFlowSlot) ? EdgeGUI.kSimpleTypeEdgeColor : EdgeGUI.kFunctionEdgeColor;
                        if (!current.toSlot.isFlowSlot && current.toSlot.dataType.IsSubclassOf(typeof(UnityEngine.Object)))
                        {
                            color = EdgeGUI.kObjectTypeEdgeColor;
                        }
                        color *= current.color;
                        EdgeGUI.DrawEdge(current, tex, color, this.edgeStyle);
                        num2++;
                    }
                }
            }
            if (EdgeGUI.s_DragSourceSlot != null && Event.current.type == EventType.MouseUp)
            {
                if (this.moveEdge != null)
                {
                    this.host.graph.RemoveEdge(this.moveEdge);
                    this.moveEdge = null;
                }
                if (EdgeGUI.s_DropTarget == null)
                {
                    this.EndDragging();
                    Event.current.Use();
                }
            }
        }
コード例 #4
0
 private static void DrawEdge(Vector2 start, Vector2 end, Texture2D tex, Color color, EdgeGUI.EdgeStyle style)
 {
     if (style != EdgeGUI.EdgeStyle.Angular)
     {
         if (style == EdgeGUI.EdgeStyle.Curvy)
         {
             Vector3[] array;
             Vector3[] array2;
             EdgeGUI.GetCurvyConnectorValues(start, end, out array, out array2);
             Handles.DrawBezier(array[0], array[1], array2[0], array2[1], color, tex, 3f);
         }
     }
     else
     {
         Vector3[] array;
         Vector3[] array2;
         EdgeGUI.GetAngularConnectorValues(start, end, out array, out array2);
         EdgeGUI.DrawRoundedPolyLine(array, array2, tex, color);
     }
 }
コード例 #5
0
        public Edge FindClosestEdge()
        {
            Vector2 mousePosition = Event.current.mousePosition;
            float   num           = float.PositiveInfinity;
            Edge    result        = null;

            foreach (Edge current in this.host.graph.edges)
            {
                Vector2 start;
                Vector2 end;
                EdgeGUI.GetEdgeEndPoints(current, out start, out end);
                Vector3[] array;
                if (this.edgeStyle == EdgeGUI.EdgeStyle.Angular)
                {
                    Vector3[] array2;
                    EdgeGUI.GetAngularConnectorValues(start, end, out array, out array2);
                }
                else
                {
                    Vector3[] array2;
                    EdgeGUI.GetCurvyConnectorValues(start, end, out array, out array2);
                }
                for (int i = 0; i < array.Length; i += 2)
                {
                    float num2 = HandleUtility.DistancePointLine(mousePosition, array[i], array[i + 1]);
                    if (num2 < num)
                    {
                        num    = num2;
                        result = current;
                    }
                }
            }
            if (num > 10f)
            {
                result = null;
            }
            return(result);
        }