Example #1
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        layoutPath = target as LayoutPath;
        if (GUILayout.Button("Import XML"))
        {
            var path = EditorUtility.OpenFilePanel("Select the XML that contains the spline path points",
                                                   "",
                                                   "xml");
            if (path.Length != 0)
            {
                layoutPath.BuildObject(path);
            }
        }
        if (selectedIndex >= 0)
        {
            if (GUILayout.Button("Remove selected point"))
            {
                layoutPath.RemoveAt(selectedIndex);
            }
        }
        if (GUILayout.Button("Clear"))
        {
            layoutPath.Clear();
        }
        insertMerker = GUILayout.Toggle(insertMerker, "Add marker");
    }
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        layoutPath = target as LayoutPath;
        if(GUILayout.Button("Import XML"))
        {
            var path = EditorUtility.OpenFilePanel("Select the XML that contains the spline path points",
                "",
                "xml");
            if (path.Length != 0)
            {
                layoutPath.BuildObject(path);
            }
        }
        if (selectedIndex >= 0)
        {
            if (GUILayout.Button("Remove selected point"))
            {
                layoutPath.RemoveAt(selectedIndex);
            }
        }
        if (GUILayout.Button("Clear"))
        {
            layoutPath.Clear();
        }
        insertMerker = GUILayout.Toggle (insertMerker, "Add marker");
    }
        public ReroutePathLayoutAction(LayoutPath path, Route oldRoute, Route newRoute)

        {
            Path     = path;
            OldRoute = oldRoute;
            NewRoute = newRoute;
        }
Example #4
0
        public IEnumerable <LayoutVertexBase> GetAffectedVertices(LayoutPath layoutPath)
        {
            var diagramNodeVertices = _layeredLayoutGraph.GetVertexAndDescendants(layoutPath.PathSource).ToList();
            var dummyVertices       = diagramNodeVertices.SelectMany(i => _layeredLayoutGraph.OutEdges(i)).SelectMany(i => i.InterimVertices);

            return(diagramNodeVertices.Concat((IEnumerable <LayoutVertexBase>)dummyVertices));
        }
        public void OnDiagramConnectorRemoved(LayoutPath layoutPath)
        {
            GetAffectedVertices(layoutPath).ForEach(RemoveFromLayers);

            _layoutGraph.RemoveEdge(layoutPath);

            GetAffectedVertices(layoutPath).OrderBy(ProperLayoutGraph.GetLayerIndex).ForEach(SetLocation);
        }
Example #6
0
 // Use this for initialization
 void Start()
 {
     currentCam   = 0;
     Distance     = 0.0f;
     OnSimulation = false;
     Sort(true);
     layout = transform.GetComponent <LayoutPath>();
 }
Example #7
0
    private void OnSceneGUI()
    {
        layoutPath = target as LayoutPath;

        handleTransform = layoutPath.transform;
        handleRotation  = Tools.pivotRotation == PivotRotation.Local ? handleTransform.rotation : Quaternion.identity;

        for (int i = 0; i < layoutPath.GetPointsCount(); ++i)
        {
            Vector3 p0 = ShowPoint(i);

            if (i < layoutPath.GetPointsCount() - 1)
            {
                Vector3 p1 = ShowPoint(i + 1);
                Handles.color = Color.white;
                Handles.DrawLine(p0, p1);
            }
        }

        if (Event.current.type == EventType.MouseUp && insertMerker)
        {
            // Shoot a ray from the mouse position into the world
            Ray        worldRay = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition);
            RaycastHit hitInfo;
            // Shoot this ray. check in a distance of 10000.
            if (Physics.Raycast(worldRay, out hitInfo, 10000))
            {
                /*
                 * // Load the current prefab
                 * string path = "Assets/Prefabs/" + __typeStrings[__currentType] + ".prefab";
                 * GameObject anchor_point = Resources.LoadAssetAtPath(path, typeof(GameObject)) as GameObject;
                 * // Instance this prefab
                 * GameObject prefab_instance = PrefabUtility.InstantiatePrefab(anchor_point) as GameObject;
                 * // Place the prefab at correct position (position of the hit).
                 * prefab_instance.transform.position = hitInfo.point;
                 * prefab_instance.transform.parent = __objectGroup.transform;
                 */
                // Mark the instance as dirty because we like dirty
                layoutPath.AddPacenote(hitInfo.point);
                //EditorUtility.SetDirty(prefab_instance);
            }
            insertMerker = false;

            /*
             * Ray ray = Camera.current.ScreenPointToRay(Event.current.mousePosition);
             * //Debug.Log(Event.current.mousePosition);
             * RaycastHit hit = new RaycastHit();
             * if (Physics.Raycast(ray, out hit, 1000.0f))
             * {
             *      //Debug.Log(hit.);
             *      layoutPath.AddPacenote(hit.point);
             *      //Vector3 newTilePosition = hit.point;
             *      //Instantiate(newTile, newTilePosition, Quaternion.identity);
             * }
             */
        }
    }
    private void OnSceneGUI()
    {
        layoutPath = target as LayoutPath;

        handleTransform = layoutPath.transform;
        handleRotation = Tools.pivotRotation == PivotRotation.Local ? handleTransform.rotation : Quaternion.identity;

        for (int i = 0; i < layoutPath.GetPointsCount(); ++i)
        {
            Vector3 p0 = ShowPoint(i);

            if (i < layoutPath.GetPointsCount() -1)
            {
                Vector3 p1 = ShowPoint(i + 1);
                Handles.color = Color.white;
                Handles.DrawLine(p0, p1);
            }
        }

        if (Event.current.type == EventType.MouseUp && insertMerker )
        {
            // Shoot a ray from the mouse position into the world
            Ray worldRay = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition);
            RaycastHit hitInfo;
            // Shoot this ray. check in a distance of 10000.
            if (Physics.Raycast(worldRay, out hitInfo, 10000))
            {
                /*
                // Load the current prefab
                string path = "Assets/Prefabs/" + __typeStrings[__currentType] + ".prefab";
                GameObject anchor_point = Resources.LoadAssetAtPath(path, typeof(GameObject)) as GameObject;
                // Instance this prefab
                GameObject prefab_instance = PrefabUtility.InstantiatePrefab(anchor_point) as GameObject;
                // Place the prefab at correct position (position of the hit).
                prefab_instance.transform.position = hitInfo.point;
                prefab_instance.transform.parent = __objectGroup.transform;
                */
                // Mark the instance as dirty because we like dirty
                layoutPath.AddPacenote(hitInfo.point);
                //EditorUtility.SetDirty(prefab_instance);
            }
            insertMerker = false;
            /*
            Ray ray = Camera.current.ScreenPointToRay(Event.current.mousePosition);
            //Debug.Log(Event.current.mousePosition);
            RaycastHit hit = new RaycastHit();
            if (Physics.Raycast(ray, out hit, 1000.0f))
            {
                //Debug.Log(hit.);
                layoutPath.AddPacenote(hit.point);
                //Vector3 newTilePosition = hit.point;
                //Instantiate(newTile, newTilePosition, Quaternion.identity);
            }
            */
        }
    }
        private static Route GetRoutePoints(LayoutPath layoutPath, LayoutVertexToPointMap vertexCenters)
        {
            var sourceRect = vertexCenters.GetRect(layoutPath.PathSource);
            var targetRect = vertexCenters.GetRect(layoutPath.PathTarget);

            var routePoints = sourceRect.Center.ToEnumerable()
                              .Concat(layoutPath.InterimVertices.Select(vertexCenters.Get))
                              .Concat(targetRect.Center.ToEnumerable());

            return(new Route(routePoints).AttachToSourceRectAndTargetRect(sourceRect, targetRect));
        }
Example #10
0
    public void Sort(bool rename)
    {
        if (layout == null)
        {
            layout = transform.GetComponent <LayoutPath>();
        }

        if (cameras == null)
        {
            // try to find a gameobject
            foreach (Transform t in transform.gameObject.transform)
            {
                if (t.name == "LayoutCameras")
                {
                    cameras = t.gameObject;
                    break;
                }
            }
            if (cameras == null)
            {
                cameras = new GameObject("LayoutCameras");
                cameras.transform.SetParent(transform);
            }
        }

        camList.Clear();
        int iCam = 0;

        foreach (Transform item in cameras.transform)
        {
            if (rename)
            {
                layout.GetPositionOnPath(item.position);
                Debug.Log(string.Format("Cam {0}, perc {1}", item.name, layout.Perc));
                camList.Add(layout.Perc * 10.0f, item.gameObject);
            }
            else
            {
                camList.Add(Convert.ToSingle(iCam), item.gameObject);
            }
            iCam++;
        }

        if (rename)
        {
            int i = 0;
            foreach (var item in camList)
            {
                item.Value.name = string.Format("{0:000}_cam", item.Key);
                item.Value.transform.SetSiblingIndex(i++);
            }
        }
    }
Example #11
0
    public bool UpdatePoints()
    {
        if (SomethingIsChanged())
        {
            try
            {
                if (layout == null)
                {
                    layout = transform.GetComponent <LayoutPath>();
                }

                Points.Clear();
                layout.GetPositionOnPath(StartDistance + StartCarRelative);
                Points.Add(layout.PosOnPath);

                layout.GetPositionOnPath(StartDistance + StartCo1Relative + StartCo0Relative);
                Points.Add(layout.PosOnPath);
                layout.GetPositionOnPath(StartDistance + StartCo1Relative);
                Points.Add(layout.PosOnPath);
                layout.GetPositionOnPath(StartDistance);
                Points.Add(layout.PosOnPath);
                layout.GetPositionOnPath(StartDistance + StartEndRelative);
                Points.Add(layout.PosOnPath);

                layout.GetPositionOnPath(Split1Distance);
                Points.Add(layout.PosOnPath);
                layout.GetPositionOnPath(Split2Distance);
                Points.Add(layout.PosOnPath);
                layout.GetPositionOnPath(Split3Distance);
                Points.Add(layout.PosOnPath);

                layout.GetPositionOnPath(FinishDistance + FinishCo0Relative);
                Points.Add(layout.PosOnPath);
                layout.GetPositionOnPath(FinishDistance);
                Points.Add(layout.PosOnPath);
                layout.GetPositionOnPath(FinishDistance + FinishStopRelative);
                Points.Add(layout.PosOnPath);
                layout.GetPositionOnPath(FinishDistance + FinishStopRelative + FinishEndRelative);
                Points.Add(layout.PosOnPath);
            }
            catch (System.Exception ex)
            {
                Debug.LogError(ex.ToString());
                return(false);
            }
        }
        return(true);
    }
Example #12
0
        private void AssociatedObjectOnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (e.AddedItems == null || e.AddedItems.Count < 1 || !AssociatedObject.LayoutPaths.Any())
            {
                return;
            }

            LayoutPath target        = AssociatedObject.LayoutPaths.First();
            int        selectedIndex = AssociatedObject.SelectedIndex;
            int        itemCount     = AssociatedObject.Items.Count;

            // アニメーションする移動量を計算する。
            double from;
            double to = DefaultStart - MaximumLength / itemCount * selectedIndex;

            target.Start = to;

            if (_previousSelectedIndex == 0 && selectedIndex == itemCount - 1)
            {
                from = DefaultStart - MaximumLength;
            }
            else if (_previousSelectedIndex == itemCount - 1 && selectedIndex == 0)
            {
                from = DefaultStart + MaximumLength / itemCount;
            }
            else
            {
                from = target.Start;
            }

            // Storyboardを作成する。
            var frames = new DoubleAnimationUsingKeyFrames();

            frames.KeyFrames.Add(new EasingDoubleKeyFrame(from, KeyTime.FromTimeSpan(TimeSpan.Zero)));
            frames.KeyFrames.Add(new EasingDoubleKeyFrame(to, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(200))));
            Storyboard.SetTarget(frames, target);
            Storyboard.SetTargetProperty(frames, new PropertyPath(LayoutPath.StartProperty));
            frames.Freeze();
            var storyboard = new Storyboard();

            storyboard.Children.Add(frames);
            storyboard.Freeze();

            AssociatedObject.BeginStoryboard(storyboard);
            _previousSelectedIndex = selectedIndex;
        }
Example #13
0
        private void AnimateStart(PathListBox pathListBox, int increment, int layoutPathIndex, int startItemIndex, Duration newDuration, bool isStoryboardInterruped)
        {
            LayoutPath layoutPath = pathListBox.LayoutPaths[layoutPathIndex];

            if (layoutPath == null || increment == 0)
            {
                return;
            }

            // Get the distance between the two elements that are being arranged to compute the distance to animate start.
            int itemCount = pathListBox.Items.Count;

            int firstIndex = 0;
            int nextIndex  = 0;

            firstIndex = PathListBoxExtensions.GetFirstArrangedIndex(pathListBox, layoutPathIndex);
            nextIndex  = (firstIndex + 1) % itemCount;

            PathListBoxItem plbiStart = (PathListBoxItem)(pathListBox.ItemContainerGenerator.ContainerFromIndex(firstIndex));
            PathListBoxItem plbiEnd   = (PathListBoxItem)(pathListBox.ItemContainerGenerator.ContainerFromIndex(nextIndex));

            if (plbiStart.IsArranged == false || plbiEnd.IsArranged == false)
            {
                if (pathListBox.WrapItems)
                {
                    while (plbiStart.IsArranged == false || plbiEnd.IsArranged == false)
                    {
                        firstIndex = (firstIndex + 1) % itemCount;
                        nextIndex  = (nextIndex + 1) % itemCount;
                        plbiStart  = (PathListBoxItem)(pathListBox.ItemContainerGenerator.ContainerFromIndex(firstIndex));
                        plbiEnd    = (PathListBoxItem)(pathListBox.ItemContainerGenerator.ContainerFromIndex(nextIndex));
                    }
                }
                else
                {
                    return;
                }
            }

            double startDx = 0;

            if (plbiStart.LocalOffset > plbiEnd.LocalOffset)
            {
                // if the Start and End cross 0
                startDx = increment * ((1 - plbiStart.LocalOffset) + plbiEnd.LocalOffset);
            }
            else
            {
                startDx = increment * (plbiEnd.LocalOffset - plbiStart.LocalOffset);
            }

            double startFrom = layoutPath.Start;
            double startTo   = layoutPath.Start;

            PropertyPath propertyPath = new PropertyPath(String.Format("(ec:PathListBox.LayoutPaths)[{0}].(ec:LayoutPath.Start)", layoutPathIndex));

            DoubleAnimation startPropertyAnimation = null;

            if (isStoryboardInterruped)
            {
                // Find the DoubleAnimation that has already been created for this LayoutPath
                for (int i = 0; i < this.startPropertyStoryboard.Children.Count; i++)
                {
                    DoubleAnimation currentAnimation = (DoubleAnimation)this.startPropertyStoryboard.Children[i];
                    PropertyPath    pp = Storyboard.GetTargetProperty(currentAnimation);
                    if (currentAnimation != null && String.Equals(pp.Path, propertyPath.Path))
                    {
                        startPropertyAnimation = currentAnimation;
                        break;
                    }
                }
                startTo = (double)startPropertyAnimation.To;
                ShowItems();
                startFrom = startTo;
            }
            else
            {
                startPropertyAnimation = new DoubleAnimation();
                Storyboard.SetTarget(startPropertyAnimation, pathListBox);
                Storyboard.SetTargetProperty(startPropertyAnimation, propertyPath);
                this.startPropertyStoryboard.Children.Add(startPropertyAnimation);
            }

            startFrom += startDx;

            int EnteringItemIndex = 0;

            if (increment > 0)
            {
                EnteringItemIndex = pathListBox.GetLastArrangedIndex(layoutPathIndex);
                EnteringItemIndex = (EnteringItemIndex + 1) % itemCount;
            }
            else
            {
                EnteringItemIndex = (pathListBox.GetFirstArrangedIndex(layoutPathIndex) - 1) % itemCount;
                if (EnteringItemIndex < 0)
                {
                    if (pathListBox.WrapItems)
                    {
                        EnteringItemIndex += itemCount;
                    }
                }
            }
            PathListBoxItem pathListBoxItem = (PathListBoxItem)pathListBox.ItemContainerGenerator.ContainerFromIndex(EnteringItemIndex);

            if (pathListBoxItem != null && this.HideEnteringItem)
            {
                this.enteringItem         = pathListBoxItem;
                this.enteringItem.Opacity = 0;
            }

            startPropertyAnimation.Duration       = newDuration;
            startPropertyAnimation.From           = startFrom + 0.0001;
            startPropertyAnimation.To             = startTo;
            startPropertyAnimation.EasingFunction = this.Ease;
        }
Example #14
0
    public void UpdateSimulation(bool forceUpdate = false)
    {
        if (OnSimulation || forceUpdate)
        {
            if (layout == null)
            {
                layout = transform.GetComponent <LayoutPath>();
            }
            if (camActual == null)
            {
                foreach (var cam in Camera.allCameras)
                {
                    if (cam.name == "ReplayActual")
                    {
                        camActual = cam;
                    }
                    else if (cam.name == "ReplayNext")
                    {
                        camNext = cam;
                    }
                }
            }

            layout.GetPositionOnPath(Distance);

            //GameObject.Find("CarSimulator").hideFlags = HideFlags.HideInInspector;
            GameObject.Find("CarSimulator").transform.position = layout.PosOnPath;

            if (camList.Count == 0)
            {
                Sort(true);
            }

            int i = 0;
            foreach (var item in camList)
            {
                if (i == currentCam)
                {
                    ReplayCamActual = item.Value.GetComponent <ReplayCamera>();
                    camActual.transform.position = item.Value.transform.position;
                    camActual.fieldOfView        = ReplayCamActual.Fov;
                    CamActualName = item.Value.name;
                    //ActualFocalLength = ReplayCamActual.FocalLength;
                }
                if (i == currentCam + 1)
                {
                    ReplayCamNext = item.Value.GetComponent <ReplayCamera>();
                    camNext.transform.position = item.Value.transform.position;
                    camNext.fieldOfView        = ReplayCamNext.Fov;
                    CamNextName = item.Value.name;
                    //NextFocalLength = ReplayCamNext.FocalLength;
                }
                i++;
            }

            if (!ReplayCamActual.IsFixed)
            {
                camActual.transform.LookAt(layout.PosOnPath);
            }
            else
            {
                camActual.transform.localRotation = ReplayCamActual.transform.localRotation;
            }
            if (!ReplayCamNext.IsFixed)
            {
                camNext.transform.LookAt(layout.PosOnPath);
            }
            else
            {
                camNext.transform.localRotation = ReplayCamNext.transform.localRotation;
            }

            if (Distance < 0.0f)
            {
                Distance = 0.0f;
            }

            if (Distance > layout.Length)
            {
                Distance = layout.Length;
            }

            // check the camera changin'
            if (Distance > ReplayCamNext.StartDistance && ReplayCamNext.StartDistance != -1)
            {
                currentCam++;
                if (camList.Count <= currentCam)
                {
                    currentCam = camList.Count - 1;
                }
            }
        }
    }
Example #15
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        layoutPath = target as LayoutPath;

        GUILayout.Space(10);
        GUILayout.Label("Import from Max spline generated", EditorStyles.boldLabel);
        GUI.backgroundColor = new Color32(157, 220, 207, 255);
        if (GUILayout.Button("Import XML"))
        {
            var path = EditorUtility.OpenFilePanel("Select the XML that contains the spline path points", "", "xml");
            if (path.Length != 0)
            {
                layoutPath.BuildObject(path);
            }
        }

        GUILayout.Space(10);
        GUI.backgroundColor = new Color(0.0f, 0.8f, 0.5176f);
        GUILayout.Label("Import from Sentieri waypoints", EditorStyles.boldLabel);
        if (GUILayout.Button("Create path"))
        {
            layoutPath.GenerateFromWaypoints();
        }
        if (GUILayout.Button("Export path"))
        {
            layoutPath.ExportFromWaypoints();
        }

        GUILayout.Space(10);
        GUILayout.Label("Import from Moose Procedural Rally stages", EditorStyles.boldLabel);
        GUI.backgroundColor = new Color32(248, 200, 81, 255);
        if (GUILayout.Button("Import spline.rsd"))
        {
            var path = EditorUtility.OpenFilePanel("Select the spline.rsd file", "", "rsd");
            if (path.Length != 0)
            {
                if (layoutPath.ImportMooseBin(path))
                {
                    EditorUtility.DisplayDialog("Moose Import", "Path imported!", "Ok!!");
                }
                else
                {
                    EditorUtility.DisplayDialog("Moose Import", "ERROR!, no points added\r\nCheck the file!", "Ok!!");
                }
            }
        }

#if VEGETATION_STUDIO || VEGETATION_STUDIO_PRO
        GUILayout.Space(10);
        GUI.backgroundColor = Color.white;
        GUILayout.Label("Vegetation Studio road mask creation", EditorStyles.boldLabel);

        layoutPath.VS_RemoveGrass        = EditorGUILayout.Toggle("Remove Grass", layoutPath.VS_RemoveGrass);
        layoutPath.VS_RemovePlants       = EditorGUILayout.Toggle("Remove Plants", layoutPath.VS_RemovePlants);
        layoutPath.VS_RemoveTrees        = EditorGUILayout.Toggle("Remove Trees", layoutPath.VS_RemoveTrees);
        layoutPath.VS_RemoveObjects      = EditorGUILayout.Toggle("Remove Objects", layoutPath.VS_RemoveObjects);
        layoutPath.VS_RemoveLargeObjects = EditorGUILayout.Toggle("Remove Large Objects", layoutPath.VS_RemoveLargeObjects);

        AwesomeTechnologies.Common.EditorFunctions.FloatRangeField("Additional Grass Perimeter", ref layoutPath.VS_AdditionalGrassPerimiter, ref layoutPath.VS_AdditionalGrassPerimiterMax, 0, 40);
        AwesomeTechnologies.Common.EditorFunctions.FloatRangeField("Additional Plant Perimeter", ref layoutPath.VS_AdditionalPlantPerimiter, ref layoutPath.VS_AdditionalPlantPerimiterMax, 0, 40);
        AwesomeTechnologies.Common.EditorFunctions.FloatRangeField("Additional Tree Perimeter", ref layoutPath.VS_AdditionalTreePerimiter, ref layoutPath.VS_AdditionalTreePerimiterMax, 0, 40);
        AwesomeTechnologies.Common.EditorFunctions.FloatRangeField("Additional Object Perimeter", ref layoutPath.VS_AdditionalObjectPerimiter, ref layoutPath.VS_AdditionalObjectPerimiterMax, 0, 40);
        AwesomeTechnologies.Common.EditorFunctions.FloatRangeField("Additional Large Perimeter", ref layoutPath.VS_AdditionalLargeObjectPerimiter, ref layoutPath.VS_AdditionalLargeObjectPerimiterMax, 0, 40);
        layoutPath.VS_LineWidth = EditorGUILayout.FloatField("Line Width", layoutPath.VS_LineWidth);

        GUILayout.Space(5);
        layoutPath.VS_SkipPoints = EditorGUILayout.IntField("Skip points", layoutPath.VS_SkipPoints);
        GUILayout.Space(5);

        GUI.backgroundColor = new Color32(99, 194, 214, 255);
        if (GUILayout.Button("Create"))
        {
            if (layoutPath.GenerateVsRoadMask())
            {
                EditorUtility.DisplayDialog("Vegetation Studio", "Road mask created!", "Ok!!");
            }
            else
            {
                EditorUtility.DisplayDialog("Vegetation Studio", "ERROR!, no road mask created!", "Ok!!");
            }
        }
#endif

        GUILayout.Space(10);
        GUILayout.Label("Utility", EditorStyles.boldLabel);
        GUI.backgroundColor = new Color32(115, 242, 252, 255);
        if (GUILayout.Button("Update Length"))
        {
            layoutPath.calcLength();
        }

        /* ??
         * GUI.backgroundColor = Color.white;
         * //GUILayout.Label("Import from Max spline generated", EditorStyles.boldLabel);
         * if (GUILayout.Button("Export XML"))
         * {
         *  var path = EditorUtility.SaveFilePanel("Select the folder to store the XML",
         *      "", "path.xml", "xml");
         *  if (path.Length != 0)
         *  {
         *      layoutPath.ExportXml(path);
         *  }
         * }*/
        if (selectedIndex >= 0)
        {
            GUI.backgroundColor = Color.red;
            if (GUILayout.Button("Remove selected point"))
            {
                layoutPath.RemoveAt(selectedIndex);
            }
        }

        GUI.backgroundColor = new Color32(220, 157, 170, 255);
        if (GUILayout.Button("Invert points"))
        {
            layoutPath.Invert();
        }

        GUI.backgroundColor = new Color(1.0f, 0.647f, 0.0f);
        if (GUILayout.Button("Clear"))
        {
            layoutPath.Clear();
        }

        GUI.backgroundColor = Color.white;
    }
Example #16
0
    void OnSceneGUI()
    {
        layoutPath = target as LayoutPath;
        Vector3[] localPoints = layoutPath.points.ToArray();
        Vector3[] worldPoints = new Vector3[layoutPath.points.Count];
        for (int i = 0; i < worldPoints.Length; i++)
        {
            worldPoints[i] = layoutPath.transform.TransformPoint(localPoints[i]);
        }

        DrawPolyLine(worldPoints);

        if (!layoutPath.EditLine)
        {
            return;
        }

        DrawNodes(worldPoints);

        if (Event.current.shift)
        {
            var newPoint = FindPoint();

            if (newPoint == Vector3.zero)
            {
                return;
            }

            var handleSize = HandleUtility.GetHandleSize(newPoint);
            var nodeIndex  = FindNearestNodeToMouse(worldPoints);
            if (nodeIndex < worldPoints.Length - 1)
            {
                if (Handles.Button(newPoint, Quaternion.identity, handleSize * 0.1f, handleSize, Handles.RectangleHandleCap))
                {
                    Undo.RecordObject(layoutPath, "Insert Node");
                    layoutPath.points.Insert(nodeIndex + 1, newPoint);
                    Event.current.Use();
                    layoutPath.calcLength();
                }
            }
            else
            {
                if (Handles.Button(newPoint, Quaternion.identity, handleSize * 0.1f, handleSize, Handles.RectangleHandleCap))
                {
                    Undo.RecordObject(layoutPath, "Insert Node");
                    layoutPath.points.Add(newPoint);
                    Event.current.Use();
                    layoutPath.calcLength();
                }
            }
        }

        if (Event.current.control)
        {
            //Deleting Points
            int indexToDelete = FindNearestNodeToMouse(worldPoints);
            Handles.color = Color.red;
            var handleSize = HandleUtility.GetHandleSize(worldPoints[0]);
            if (Handles.Button(worldPoints[indexToDelete], Quaternion.identity, handleSize * 0.09f, handleSize, Handles.RectangleHandleCap))
            {
                Undo.RecordObject(layoutPath, "Remove Node");
                layoutPath.points.RemoveAt(indexToDelete);
                indexToDelete = -1;
                Event.current.Use();
                layoutPath.calcLength();
            }

            Handles.color = Color.white;
        }

        if (GUI.changed)
        {
            EditorUtility.SetDirty(layoutPath);
        }
    }
Example #17
0
 public bool Equals(ViewDefinition other)
 {
     return(LayoutPath.Equals(other.LayoutPath, StringComparison.OrdinalIgnoreCase) &&
            ViewPath.Equals(other.ViewPath, StringComparison.OrdinalIgnoreCase));
 }
Example #18
0
 public void AddEdge(LayoutPath edge)
 {
     GetAffectedVertices(edge).ForEach(RemoveFromLayers);
     _layeredLayoutGraph.AddEdge(edge);
     GetAffectedVertices(edge).OrderBy(ProperLayeredLayoutGraph.GetLayerIndex).ForEach(SetLocation);
 }