예제 #1
0
파일: Graph.cs 프로젝트: despin89/repo
        public void UnLink(AbstractSocket socket)
        {
            if ((socket == null) || !socket.IsConnected())
            {
                return;
            }


            if (socket.IsInput())
            {
                InputSocket inputSocket = (InputSocket)socket;
                if (inputSocket.Connection != null)
                {
                    this.UnLink(inputSocket, inputSocket.Connection.Output);
                }
            }

            if (socket.IsOutput())
            {
                OutputSocket outputSocket   = (OutputSocket)socket;
                Connection[] connectionCopy = new Connection[outputSocket.Connections.Count];
                outputSocket.Connections.CopyTo(connectionCopy);
                foreach (Connection edge in connectionCopy)
                {
                    this.UnLink(edge.Input, outputSocket);
                }
            }
        }
예제 #2
0
        public void Draw(EditorWindow window, Rect region, AbstractSocket currentDragingSocket)
        {
            if (this.centeredLabelStyle == null)
            {
                this.centeredLabelStyle = GUI.skin.GetStyle("Label");
            }
            this.centeredLabelStyle.alignment = TextAnchor.MiddleCenter;

            EditorZoomArea.Begin(this.Zoom, region);

            if (this.Style.normal.background == null)
            {
                this.Style.normal.background = this.CreateBackgroundTexture();
            }
            GUI.DrawTextureWithTexCoords(this.DrawArea, this.Style.normal.background, new Rect(0, 0, 1000, 1000));
            this.DrawArea.Set(this.Position.x, this.Position.y, CanvasSize, CanvasSize);
            GUILayout.BeginArea(this.DrawArea);
            this.DrawEdges();
            window.BeginWindows();
            this.DrawNodes();
            window.EndWindows();
            this.DrawDragEdge(currentDragingSocket);

            for (int i = 0; i < this.Graph.GetNodeCount(); i++)
            {
                this.Graph.GetNodeAt(i).GUIDrawSockets();
            }

            GUILayout.EndArea();
            EditorZoomArea.End();
        }
예제 #3
0
 public static void TriggerOnUnLinkedSockets(Graph graph, AbstractSocket socket01, AbstractSocket socket02)
 {
     if (OnUnLinkedSockets != null)
     {
         OnUnLinkedSockets(graph, socket01, socket02);
     }
 }
예제 #4
0
파일: Connection.cs 프로젝트: despin89/repo
        public static Vector2 GetTangentPosition(AbstractSocket socket, Vector2 position)
        {
            if (socket.IsInput())
            {
                return(position + Vector2.left * NodeEditorConfig.EdgeTangent);
            }

            return(position + Vector2.right * NodeEditorConfig.EdgeTangent);
        }
예제 #5
0
파일: Connection.cs 프로젝트: despin89/repo
        public AbstractSocket GetOtherSocket(AbstractSocket socket)
        {
            if (socket == this.Input)
            {
                return(this.Output);
            }

            return(this.Input);
        }
예제 #6
0
 private void DrawDragEdge(AbstractSocket currentDragingSocket)
 {
     if (currentDragingSocket != null)
     {
         this._tmpVector01 = Connection.GetEdgePosition(currentDragingSocket, this._tmpVector01);
         this._tmpVector02 = Connection.GetTangentPosition(currentDragingSocket, this._tmpVector01);
         Connection.DrawEdge(this._tmpVector01, this._tmpVector02, Event.current.mousePosition,
                             Event.current.mousePosition,
                             currentDragingSocket.Type);
     }
 }
예제 #7
0
 private void HandleSocketDrop(AbstractSocket dropTarget)
 {
     if ((dropTarget != null) && (dropTarget.GetType() != this._dragSourceSocket.GetType()))
     {
         if (dropTarget.IsInput())
         {
             this._currentCanvas.Graph.Link((InputSocket)dropTarget, (OutputSocket)this._dragSourceSocket);
         }
         Event.current.Use();
     }
     this._dragSourceSocket = null;
     this.Repaint();
 }
예제 #8
0
        /// <summary> Returns the socket at the window position.</summary>
        /// <param name="windowPosition"> The position to get the Socket from in window coordinates</param>
        /// <returns>The socket at the posiiton or null or null.</returns>
        public AbstractSocket GetSocketAt(Vector2 windowPosition)
        {
            Vector2 projectedPosition = this.ProjectToCanvas(windowPosition);

            for (int i = 0; i < this.Graph.GetNodeCount(); i++)
            {
                Node           node   = this.Graph.GetNodeAt(i);
                AbstractSocket socket = node.SearchSocketAt(projectedPosition);
                if (socket != null)
                {
                    return(socket);
                }
            }

            return(null);
        }
예제 #9
0
 private void HandleSocketDrag(AbstractSocket dragSource)
 {
     if (dragSource != null)
     {
         if (dragSource.IsInput() && dragSource.IsConnected())
         {
             this._dragSourceSocket = ((InputSocket)dragSource).Connection.GetOtherSocket(dragSource);
             this._currentCanvas.Graph.UnLink((InputSocket)dragSource, (OutputSocket)this._dragSourceSocket);
         }
         if (dragSource.IsOutput())
         {
             this._dragSourceSocket = dragSource;
         }
         Event.current.Use();
     }
     this.Repaint();
 }
예제 #10
0
파일: Connection.cs 프로젝트: despin89/repo
 public static Vector2 GetEdgePosition(AbstractSocket socket, Vector2 position)
 {
     if (socket.Parent.Collapsed)
     {
         float width = NodeEditorConfig.SocketSize;
         if (socket.IsOutput())
         {
             width = 0;
         }
         position.Set(socket.X + width, socket.Parent.WindowRect.y + 8);
     }
     else
     {
         float width = 0;
         if (socket.IsOutput())
         {
             width = NodeEditorConfig.SocketSize;
         }
         position.Set(socket.X + width, socket.Y + NodeEditorConfig.SocketSize / 2f);
     }
     return(position);
 }
예제 #11
0
 /// <summary> Returns true if this node contains the assigned socket.</summary>
 /// <param name="socket"> The socket to use.</param>
 /// <returns>True if this node contains the assigned socket.</returns>
 public bool ContainsSocket(AbstractSocket socket)
 {
     return(this.Sockets.Contains(socket));
 }