Example #1
0
        private void OnSceneGUI()
        {
            SplineObject obj = (SplineObject)target;

            Handles.color = new Color(1, 0.5f, 0, 1);
            SplineEditor.DrawSplineSys(obj.splines, obj.transform.localToWorldMatrix,
                                       drawLines: obj.drawLines, drawBeizer: obj.drawBeizer, drawNodes: obj.drawNodes);

            SplineEditor.EditSplineSys(obj.splines, obj.transform.localToWorldMatrix, obj);
        }
Example #2
0
        static void DrawInactiveGizmo(SplineObject obj, GizmoType gizmoType)
        {
            //drawing selected in OnSceneGUI - otherwise will be erased by matrix gizmo drawn in tester's OnSceneGUI

            if (gizmoType.HasFlag(GizmoType.NonSelected))
            {
                Handles.color = new Color(0.75f, 0.25f, 0, 1);
                SplineEditor.DrawSplineSys(obj.splines, obj.transform.localToWorldMatrix,
                                           drawLines: obj.drawLines, drawBeizer: obj.drawBeizer, drawNodes: obj.drawNodes);
            }
        }
        /*UI ui = new UI();
         * SplineObject so;
         *
         * public void OnSceneGUI ()
         * {
         *      if (so == null) so = (SplineObject)target;
         *      ui.DrawInspector(() => DrawSpline(so.splineSys));
         * }*/


        public static void DrawSpline(SplineObject obj)
        {
            using (Cell.LineStd)
                using (new Draw.FoldoutGroup(ref guiDisplay, "Display", isLeft: true))
                    if (guiDisplay)
                    {
                        using (Cell.LineStd) Draw.ToggleLeft(ref obj.drawNodes, "Draw Nodes");
                        using (Cell.LineStd) Draw.ToggleLeft(ref obj.drawLines, "Draw Segments");
                        using (Cell.LineStd) Draw.ToggleLeft(ref obj.drawBeizer, "Draw Beizer");

                        if (Cell.current.valChanged)
                        {
                            SceneView.lastActiveSceneView?.Repaint();
                        }
                    }

            Cell.EmptyLinePx(4);
            using (Cell.LineStd)
                using (new Draw.FoldoutGroup(ref guiLines, "Splines", isLeft: true))
                    if (guiLines)
                    {
                        using (Cell.LineStd) Draw.DualLabel("Lines Count", obj.splines.Length.ToString());

                        if (SplineEditor.selectedNodes.Count == 1)
                        {
                            (int l, int n) = SplineEditor.selectedNodes.Any();
                            Spline spline = obj.splines[l];

                            //using (Cell.LineStd) Draw.DualLabel("Length", spline.length.ToString());
                            using (Cell.LineStd) Draw.DualLabel("Node Counts", spline.nodes.Length.ToString());
                            //using (Cell.LineStd) Draw.Toggle(ref spline.looped, "Looped");

                            using (Cell.LineStd)
                                if (Draw.Button("Remove"))
                                {
                                    ArrayTools.RemoveAt(ref obj.splines, l);
                                    SplineEditor.selectedNodes.Clear();
                                    SplineEditor.dispSelectedNodes.Clear();
                                }
                        }

                        using (Cell.LineStd)
                            if (Draw.Button("Add"))
                            {
                                Spline newSpline = new Spline(
                                    SceneView.lastActiveSceneView.pivot - new Vector3(SceneView.lastActiveSceneView.cameraDistance / 10, 0, 0),
                                    SceneView.lastActiveSceneView.pivot + new Vector3(SceneView.lastActiveSceneView.cameraDistance / 10, 0, 0));
                                newSpline.nodes[0].y = 0;
                                newSpline.nodes[1].y = 0;

                                ArrayTools.Add(ref obj.splines, newSpline);
                            }
                    }

            Cell.EmptyLinePx(4);
            using (Cell.LineStd)
                using (new Draw.FoldoutGroup(ref guiKnobs, "Nodes", isLeft: true))
                    if (guiKnobs)
                    {
                        using (Cell.LineStd) Draw.DualLabel("Selected", SplineEditor.selectedNodes.Count.ToString());

                        if (SplineEditor.selectedNodes.Count == 1)
                        {
                            Cell.EmptyLinePx(4);
                            (int l, int n) = SplineEditor.selectedNodes.Any();
                            using (Cell.LinePx(0)) DrawNode(obj.splines, l, n);
                        }
                    }

            /*Cell.EmptyLinePx(4);
             * using (Cell.LineStd)
             *      if (Draw.Button("Update"))
             *      {
             *              sys.Update();
             *              SceneView.lastActiveSceneView?.Repaint();
             *      }*/
        }
Example #4
0
        private void DrawGUI()
        {
            SplineObject splineObj = (SplineObject)target;

            SplineInspector.DrawSpline(splineObj);
        }