private void Main()
        {
            Rect barRect = new Rect(0f, 0f, Screen.width, 45 * scale);

            if (barRect.Contains(Event.current.mousePosition))
            {
                mouseHoversToolbar = true;
            }
            GUI.color = new Color(1f, 1f, 1f, 0.3f);
            GUI.Box(barRect, "", SplineEditorGUI.whiteBox);
            GUI.color = SplineEditorGUI.activeColor;

            if (computer.hasMorph && !MorphWindow.editShapeMode)
            {
                DreamteckEditorGUI.Label(new Rect(Screen.width / 2f - 200f, 10, 400, 30), "Editing unavailable outside of morph states.");
                return;
            }
            if (computer.hasMorph)
            {
                if (tool == PointTool.Create || tool == PointTool.Delete)
                {
                    tool = PointTool.None;
                }
            }
            else
            {
                if (SplineEditorGUI.BigButton(new Rect(5 * scale, 5 * scale, 35 * scale, 35 * scale), addButtonContent, true, tool == PointTool.Create))
                {
                    ToggleCreateTool();
                }
                if (SplineEditorGUI.BigButton(new Rect(45 * scale, 5 * scale, 35 * scale, 35 * scale), removeButtonContent, computer.pointCount > 0, tool == PointTool.Delete))
                {
                    if (tool != PointTool.Delete)
                    {
                        tool = PointTool.Delete;
                    }
                    else
                    {
                        tool = PointTool.None;
                    }
                }
                if (SplineEditorGUI.BigButton(new Rect(85 * scale, 5 * scale, 35 * scale, 35 * scale), presetButtonContent, true, presetWindow != null))
                {
                    if (presetWindow == null)
                    {
                        presetWindow = EditorWindow.GetWindow <PresetsWindow>(true);
                        presetWindow.Init(this, Vector2.zero, new Vector2(350, 20 * 22));
                    }
                }
            }

            if (SplineEditorGUI.BigButton(new Rect(150 * scale, 5 * scale, 35 * scale, 35 * scale), moveButtonContent, true, tool == PointTool.Move))
            {
                if (tool != PointTool.Move)
                {
                    ToggleMoveTool();
                }
                else
                {
                    tool = PointTool.None;
                }
            }
            if (SplineEditorGUI.BigButton(new Rect(190 * scale, 5 * scale, 35 * scale, 35 * scale), rotateButtonContent, true, tool == PointTool.Rotate))
            {
                if (tool != PointTool.Rotate)
                {
                    ToggleRotateTool();
                }
                else
                {
                    tool = PointTool.None;
                }
            }
            if (SplineEditorGUI.BigButton(new Rect(230 * scale, 5 * scale, 35 * scale, 35 * scale), scaleButtonContent, true, tool == PointTool.Scale))
            {
                if (tool != PointTool.Scale)
                {
                    ToggleScaleTool();
                }
                else
                {
                    tool = PointTool.None;
                }
            }
            if (SplineEditorGUI.BigButton(new Rect(270 * scale, 5 * scale, 35 * scale, 35 * scale), normalsButtonContent, !computer.is2D, tool == PointTool.NormalEdit))
            {
                if (tool != PointTool.NormalEdit)
                {
                    tool = PointTool.NormalEdit;
                }
                else
                {
                    tool = PointTool.None;
                }
            }
            if (SplineEditorGUI.BigButton(new Rect(330 * scale, 5 * scale, 35 * scale, 35 * scale), mirrorButtonContent, computer.pointCount > 0 || InMirrorMode(), InMirrorMode()))
            {
                if (InMirrorMode())
                {
                    ExitMirrorMode();
                }
                else
                {
                    EnterMirrorMode();
                }
            }

            if (SplineEditorGUI.BigButton(new Rect(370 * scale, 5 * scale, 35 * scale, 35 * scale), mergeButtonContent, computer.pointCount > 0 && !computer.isClosed, InMergeMode()))
            {
                if (InMergeMode())
                {
                    ExitMergeMode();
                }
                else
                {
                    EnterMergeMode();
                }
            }

            if (SplineEditorGUI.BigButton(new Rect(410 * scale, 5 * scale, 35 * scale, 35 * scale), splitButtonContent, computer.pointCount > 0 && !computer.isClosed, InSplitMode()))
            {
                if (InSplitMode())
                {
                    ExitSplitMode();
                }
                else
                {
                    EnterSplitMode();
                }
            }
            int   operation          = 0;
            float operationsPosition = Screen.width - (190 * scale + 100);

#if UNITY_EDITOR_OSX
            operationsPosition = 430 * scale;
#endif

            bool hover = SplineEditorGUI.DropDown(new Rect(operationsPosition, 10 * scale, 150 * scale, 25 * scale), SplineEditorGUI.defaultButton, operations, HasSelection(), ref operation);
            if (hover)
            {
                mouseHoversToolbar = true;
            }
            if (selectedPointsCount > 0)
            {
                switch (operation)
                {
                case 1: CenterSelection(); break;

                case 2: MoveTransformToSelection(); break;

                case 3: FlatSelection(0); break;

                case 4: FlatSelection(1); break;

                case 5: FlatSelection(2); break;

                case 6: MirrorSelection(0); break;

                case 7: MirrorSelection(1); break;

                case 8: MirrorSelection(2); break;

                case 9: DistributeEvenly(); break;

                case 10: EditorWindow.GetWindow <RelaxWindow>(true).Init(this, new Vector2(250, 90)); break;
                }
            }
            GUI.color = SplineEditorGUI.activeColor;
            ((SplineComputer)target).editorPathColor = EditorGUI.ColorField(new Rect(operationsPosition + 160 * scale, 13 * scale, 40 * scale, 20 * scale), ((SplineComputer)target).editorPathColor);
        }
Exemplo n.º 2
0
        private void Main()
        {
            Rect barRect = new Rect(0f, 0f, Screen.width, 45 * scale);

            if (barRect.Contains(Event.current.mousePosition))
            {
                mouseHovers = true;
            }
            GUI.color = new Color(1f, 1f, 1f, 0.3f);
            GUI.Box(barRect, "", SplineEditorGUI.whiteBox);
            GUI.color = SplineEditorGUI.activeColor;
            if (computer.hasMorph && !MorphWindow.editShapeMode)
            {
                SplineEditorGUI.Label(new Rect(Screen.width / 2f - 200f, 10, 400, 30), "Editing unavailable outside of morph states.");
                return;
            }
            if (computer.hasMorph)
            {
                if (editor.tool == SplineEditor.PointTool.Create || editor.tool == SplineEditor.PointTool.Delete)
                {
                    editor.tool = SplineEditor.PointTool.None;
                }
            }
            else
            {
                if (SplineEditorGUI.BigButton(new Rect(5 * scale, 5 * scale, 35 * scale, 35 * scale), addButtonContent, true, editor.tool == SplineEditor.PointTool.Create))
                {
                    editor.ToggleCreateTool();
                }
                if (SplineEditorGUI.BigButton(new Rect(45 * scale, 5 * scale, 35 * scale, 35 * scale), removeButtonContent, computer.pointCount > 0, editor.tool == SplineEditor.PointTool.Delete))
                {
                    if (editor.tool != SplineEditor.PointTool.Delete)
                    {
                        editor.tool = SplineEditor.PointTool.Delete;
                    }
                    else
                    {
                        editor.tool = SplineEditor.PointTool.None;
                    }
                }
                if (SplineEditorGUI.BigButton(new Rect(85 * scale, 5 * scale, 35 * scale, 35 * scale), presetButtonContent, true, presetWindow != null))
                {
                    if (presetWindow == null)
                    {
                        presetWindow = EditorWindow.GetWindow <PresetsWindow>();
                        presetWindow.init(editor, "Primitives & Presets", new Vector3(200, 200));
                    }
                }
            }

            if (SplineEditorGUI.BigButton(new Rect(150 * scale, 5 * scale, 35 * scale, 35 * scale), moveButtonContent, true, editor.tool == SplineEditor.PointTool.Move))
            {
                if (editor.tool != SplineEditor.PointTool.Move)
                {
                    editor.ToggleMoveTool();
                }
                else
                {
                    editor.tool = SplineEditor.PointTool.None;
                }
            }
            if (SplineEditorGUI.BigButton(new Rect(190 * scale, 5 * scale, 35 * scale, 35 * scale), rotateButtonContent, true, editor.tool == SplineEditor.PointTool.Rotate))
            {
                if (editor.tool != SplineEditor.PointTool.Rotate)
                {
                    editor.ToggleRotateTool();
                }
                else
                {
                    editor.tool = SplineEditor.PointTool.None;
                }
            }
            if (SplineEditorGUI.BigButton(new Rect(230 * scale, 5 * scale, 35 * scale, 35 * scale), scaleButtonContent, true, editor.tool == SplineEditor.PointTool.Scale))
            {
                if (editor.tool != SplineEditor.PointTool.Scale)
                {
                    editor.ToggleScaleTool();
                }
                else
                {
                    editor.tool = SplineEditor.PointTool.None;
                }
            }
            if (SplineEditorGUI.BigButton(new Rect(270 * scale, 5 * scale, 35 * scale, 35 * scale), normalsButtonContent, true, editor.tool == SplineEditor.PointTool.NormalEdit))
            {
                if (editor.tool != SplineEditor.PointTool.NormalEdit)
                {
                    editor.tool = SplineEditor.PointTool.NormalEdit;
                }
                else
                {
                    editor.tool = SplineEditor.PointTool.None;
                }
            }
            if (SplineEditorGUI.BigButton(new Rect(330 * scale, 5 * scale, 35 * scale, 35 * scale), mirrorButtonContent, computer.pointCount > 0 || editor.InMirrorMode(), editor.InMirrorMode()))
            {
                if (editor.InMirrorMode())
                {
                    editor.ExitMirrorMode();
                }
                else
                {
                    editor.EnterMirrorMode();
                }
            }

            if (SplineEditorGUI.BigButton(new Rect(370 * scale, 5 * scale, 35 * scale, 35 * scale), mergeButtonContent, computer.pointCount > 0 && !computer.isClosed, editor.InMergeMode()))
            {
                if (editor.InMergeMode())
                {
                    editor.ExitMergeMode();
                }
                else
                {
                    editor.EnterMergeMode();
                }
            }

            int           operation = 0;
            List <string> options   = new List <string>();

            options.Add("Operations");
            if (editor.selectedPointsCount > 0)
            {
                options.Add("Center to Transform");
                options.Add("Move Transform to");
            }
            if (editor.selectedPointsCount >= 2)
            {
                options.Add("Flat X");
                options.Add("Flat Y");
                options.Add("Flat Z");
                options.Add("Mirror X");
                options.Add("Mirror Y");
                options.Add("Mirror Z");
            }
            if (editor.selectedPointsCount >= 3)
            {
                options.Add("Distribute evenly");
            }
            bool hover = SplineEditorGUI.DropDown(new Rect(Screen.width - (190 * scale + 100), 10 * scale, 150 * scale, 25 * scale), SplineEditorGUI.defaultButton, options.ToArray(), editor.HasSelection(), ref operation);

            if (hover)
            {
                mouseHovers = true;
            }
            if (operation > 0)
            {
                if (operation == 1 && editor.selectedPointsCount > 0)
                {
                    editor.CenterSelection();
                }
                else if (operation == 2 && editor.selectedPointsCount > 0)
                {
                    editor.MoveTransformToSelection();
                }
                if (editor.selectedPointsCount >= 2)
                {
                    if (operation <= 5)
                    {
                        editor.FlatSelection(operation - 3);
                    }
                    else if (operation <= 8)
                    {
                        editor.MirrorSelection(operation - 6);
                    }
                    else if (operation == 9)
                    {
                        editor.DistributeEvenly();
                    }
                }
            }
            GUI.color = SplineEditorGUI.activeColor;
            ((SplineComputer)editor.target).editorPathColor = EditorGUI.ColorField(new Rect(Screen.width - (30 * scale + 100), 13 * scale, 40 * scale, 20 * scale), ((SplineComputer)editor.target).editorPathColor);
        }