示例#1
0
        public static void DrawSceneGUI(Camera sceneviewCamera, Node node)
        {
            if (node == null)
            {
                return;
            }

            var         pos          = node.NodePosition;
            const float cullDistance = 500;
            var         sqrDist      = (sceneviewCamera.transform.position.xz() - pos.xz()).sqrMagnitude;

            if (sqrDist > cullDistance * cullDistance)
            {
                return;
            }

            Handles.color = RoadNetworkWindow.IsSelected(node) ? Color.red : Color.gray;
            if (RoadNetworkWindow.IsHovering(node))
            {
                Handles.color = Color.Lerp(Handles.color, Color.white, 0.5f);
            }

            var rot = node.transform.rotation;

            Handles.CubeHandleCap(-1, pos, rot, RoadNetworkWindow.NodePreviewSize, EventType.Repaint);

            if (RoadNetworkWindow.IsSelected(node))
            {
                if (node.Configuration.IsExplicitControl)
                {
                    Handles.color = Color.green;
                    Handles.DrawDottedLine(pos, pos + node.GetNodeControl(null), 3);
                }
                if (node.Configuration.SnappingMode == NodeConfiguration.ESnappingMode.Raycast)
                {
                    Handles.color = Color.gray;
                    Handles.DrawDottedLine(pos + Vector3.up * node.Configuration.SnapDistance / 2, pos - Vector3.up * node.Configuration.SnapDistance / 2, 1);
                }
            }
        }
示例#2
0
        public static void DrawSplineSceneGUI(Camera sceneviewCamera, NodeConnection connection)
        {
            var startColor = connection.Configuration != null ? connection.Configuration.PreviewColor : Color.gray;

            /*
             * float h, s, v;
             * Color.RGBToHSV(startColor, out h, out s, out v);
             * var endColor = Color.HSVToRGB(h + .5f, s, v);*/

            if (RoadNetworkWindow.IsSelected(connection) || RoadNetworkWindow.IsSelected(connection.NextNode))
            {
                var spline     = connection.GetSpline(true);
                var pointCount = Mathf.Min(spline.Points.Count, 30);
                int lastIndex  = 0;
                for (int i = 1; i < pointCount; i++)
                {
                    var percentageThrough = i / (float)pointCount;
                    var index             = Mathf.FloorToInt(percentageThrough * spline.Points.Count);

                    //Handles.color = Color.Lerp(startColor, endColor, percentageThrough);
                    Handles.color = startColor;
                    Handles.DrawLine(spline.Points[lastIndex].Position, spline.Points[index].Position);

                    lastIndex = index;
                }
                Handles.color = startColor;
                if (pointCount > 0)
                {
                    Handles.DrawLine(spline.Points[lastIndex].Position, spline.Points[spline.Points.Count - 1].Position);
                }
            }
            else
            {
                Handles.color = startColor;
                Handles.DrawLine(connection.ThisNode.NodePosition, connection.NextNode.NodePosition);
            }
        }