Пример #1
0
        void DrawPreviewConnection()
        {
            if (canvas.previewConnection == null)
            {
                return;
            }

            Vector2[] p             = canvas.previewConnection.Points;
            Vector3[] pointsVector3 = new Vector3[]
            {
                CanvasUtility.WorldToCanvasPoint(new Vector3(p[0].x, p[0].y, 0), canvas.canvasState),
                CanvasUtility.WorldToCanvasPoint(new Vector3(p[1].x, p[1].y, 0), canvas.canvasState),
                CanvasUtility.WorldToCanvasPoint(new Vector3(p[2].x, p[2].y, 0), canvas.canvasState),
                CanvasUtility.WorldToCanvasPoint(new Vector3(p[3].x, p[3].y, 0), canvas.canvasState)
            };

            Handles.DrawLines(pointsVector3, new int[] { 0, 1, 1, 2, 2, 3 });
        }
Пример #2
0
        void DrawConnections()
        {
            for (int i = 0; i < canvas.canvasState.nodePanels.Count; i++)
            {
                NodePanel panel = canvas.canvasState.nodePanels[i];

                if (panel.outHandle == null || panel.outHandle.Connections == null || panel.outHandle.Connections.Count == 0)
                {
                    continue;
                }

                NodeConnection runningConnection = null;

                for (int j = 0; j < panel.outHandle.Connections.Count; j++)
                {
                    NodeConnection connection = panel.outHandle.Connections[j];

                    Handles.color = !Application.isPlaying ? Color.white : new Color(0.5f, 0.5f, 0.5f, 1.0f);

                    if (Application.isPlaying)
                    {
                        // highlight connections that are running
                        if (connection.StartPanel.Node.CurrentChild == connection.EndPanel.Node)
                        {
                            runningConnection = connection;
                        }
                    }

                    Vector2[] p             = connection.Points;
                    Vector3[] pointsVector3 =
                    {
                        CanvasUtility.WorldToCanvasPoint(new Vector3(p[0].x, p[0].y, 0), canvas.canvasState),
                        CanvasUtility.WorldToCanvasPoint(new Vector3(p[1].x, p[1].y, 0), canvas.canvasState),
                        CanvasUtility.WorldToCanvasPoint(new Vector3(p[2].x, p[2].y, 0), canvas.canvasState),
                        CanvasUtility.WorldToCanvasPoint(new Vector3(p[3].x, p[3].y, 0), canvas.canvasState)
                    };

                    Handles.DrawLines(pointsVector3, new int[] { 0, 1, 1, 2, 2, 3 });
                }

                if (runningConnection != null)
                {
                    Handles.color = runningConnection.EndPanel.Node.State == Node.NodeState.Failure ?
                                    BehaviourEditorStyles.playMode_nodeFailureColour : BehaviourEditorStyles.playMode_nodeRunningColour;

                    Vector2[] p             = runningConnection.Points;
                    Vector3[] pointsVector3 = null;

                    if (Math.Abs(p[0].x - p[3].x) < 0.01f)
                    {
                        pointsVector3 = new Vector3[] {
                            CanvasUtility.WorldToCanvasPoint(new Vector3(p[0].x, p[0].y, 0), canvas.canvasState),
                            CanvasUtility.WorldToCanvasPoint(new Vector3(p[3].x, p[3].y, 0), canvas.canvasState),
                        };
                    }
                    else
                    {
                        pointsVector3 = new Vector3[] {
                            CanvasUtility.WorldToCanvasPoint(new Vector3(p[0].x, p[0].y, 0), canvas.canvasState),
                            CanvasUtility.WorldToCanvasPoint(new Vector3(p[1].x, p[1].y, 0), canvas.canvasState),
                            CanvasUtility.WorldToCanvasPoint(new Vector3(p[2].x, p[2].y, 0), canvas.canvasState),
                            CanvasUtility.WorldToCanvasPoint(new Vector3(p[3].x, p[3].y, 0), canvas.canvasState)
                        };
                    }

                    Handles.DrawAAPolyLine(10, pointsVector3.Length, pointsVector3);
                }
            }
        }