Exemplo n.º 1
0
        static void OnGUIContents(bool isSceneGUI, MeshEditBrushTool tool)
        {
            CommonGUI.StartToolGUI();

            var filteredSelection = CSGBrushEditorManager.FilteredSelection;

            var defaultMaterial = CSGSettings.DefaultMaterial;

            GUILayout.BeginVertical(isSceneGUI ? InSceneWidth : GUIStyleUtility.ContentEmpty);
            {            /*
                          *     GUILayout.BeginHorizontal(GUIStyleUtility.ContentEmpty);
                          *     {
                          *
                          *             GUILayout.BeginVertical(isSceneGUI ? GUI.skin.box : GUIStyle.none);
                          *             {
                          *                     //GUILayout.Label(Keys.VerticalMoveMode.ToString() + " to dragging brush up/down", EditorStyles.miniLabel);
                          *                     GUILayout.Label("Control (hold) to drag polygon on it's plane", EditorStyles.miniLabel);
                          *                     GUILayout.Label("Shift (hold) to drag extrude polygon", EditorStyles.miniLabel);
                          *                     GUILayout.Label("Shift (hold) to chamfer edges and vertices", EditorStyles.miniLabel);
                          *             }
                          *             GUILayout.EndVertical();
                          *     }
                          *     GUILayout.EndHorizontal();*/
                ChooseCSGOperation(filteredSelection, isSceneGUI, tool);
                GUILayout.BeginHorizontal(GUIStyleUtility.ContentEmpty);
                {
                    if (isSceneGUI)
                    {
                        GUILayout.BeginVertical(GUIStyleUtility.ContentEmpty);
                        {
                            EditorGUI.BeginChangeCheck();
                            {
                                defaultMaterial = GUIStyleUtility.MaterialImage(defaultMaterial, small: true);
                            }
                            if (EditorGUI.EndChangeCheck() && defaultMaterial)
                            {
                                CSGSettings.DefaultMaterial = defaultMaterial;
                                CSGSettings.Save();
                            }
                        }
                        GUILayout.EndVertical();
                    }
                    GUILayout.BeginVertical(GUIStyleUtility.ContentEmpty);
                    {
                        bool have_nodes = tool != null && (filteredSelection.NodeTargets.Length > 0);

                        EditorGUI.BeginDisabledGroup(!have_nodes);
                        {
                            GUIStyle left   = EditorStyles.miniButtonLeft;
                            GUIStyle middle = EditorStyles.miniButtonMid;
                            GUIStyle right  = EditorStyles.miniButtonRight;

                            GUILayout.BeginHorizontal(GUIStyleUtility.ContentEmpty);
                            {
                                if (isSceneGUI)
                                {
                                    EditorGUILayout.LabelField(ContentFlip, labelWidth);
                                }
                                else
                                {
                                    EditorGUILayout.LabelField(ContentFlip, largeLabelWidth);
                                }
                                if (GUILayout.Button(ContentFlipX, left))
                                {
                                    tool.FlipX();
                                }
                                TooltipUtility.SetToolTip(TooltipFlipX);
                                if (GUILayout.Button(ContentFlipY, middle))
                                {
                                    tool.FlipY();
                                }
                                TooltipUtility.SetToolTip(TooltipFlipY);
                                if (GUILayout.Button(ContentFlipZ, right))
                                {
                                    tool.FlipZ();
                                }
                                TooltipUtility.SetToolTip(TooltipFlipZ);
                            }
                            GUILayout.EndHorizontal();

                            /*
                             * EditorGUILayout.LabelField(ContentEdgesLabel);
                             * GUILayout.BeginHorizontal(GUIStyleUtility.ContentEmpty);
                             * {
                             *      EditorGUI.BeginDisabledGroup(!tool.CanSmooth());
                             *      {
                             *              if (GUILayout.Button("Smooth"))		{ tool.Smooth(); }
                             *      }
                             *      EditorGUI.EndDisabledGroup();
                             *      EditorGUI.BeginDisabledGroup(!tool.CanUnSmooth());
                             *      {
                             *              if (GUILayout.Button("Un-smooth"))	{ tool.UnSmooth(); }
                             *      }
                             *      EditorGUI.EndDisabledGroup();
                             * }
                             * GUILayout.EndHorizontal();
                             */

                            if (GUILayout.Button(ContentSnapToGrid))
                            {
                                tool.SnapToGrid();
                            }
                            TooltipUtility.SetToolTip(TooltipSnapToGrid);
                        }
                        EditorGUI.EndDisabledGroup();
                    }
                    GUILayout.EndVertical();
                }
                GUILayout.EndHorizontal();
                GUILayout.Space(2);
                if (!isSceneGUI)
                {
                    EditorGUILayout.Space();
                    GUILayout.BeginHorizontal(GUIStyleUtility.ContentEmpty);
                    {
                        EditorGUILayout.LabelField(ContentDefaultMaterial, largeLabelWidth);
                        GUILayout.BeginVertical(GUIStyleUtility.ContentEmpty);
                        {
                            EditorGUI.BeginChangeCheck();
                            {
                                defaultMaterial = EditorGUILayout.ObjectField(defaultMaterial, typeof(Material), true) as Material;
                            }
                            if (EditorGUI.EndChangeCheck() && defaultMaterial)
                            {
                                CSGSettings.DefaultMaterial = defaultMaterial;
                                CSGSettings.Save();
                            }
                        }
                        GUILayout.Space(2);
                        GUILayout.BeginHorizontal(GUIStyleUtility.ContentEmpty);
                        {
                            GUILayout.Space(5);
                            defaultMaterial = GUIStyleUtility.MaterialImage(defaultMaterial, small: false);
                        }
                        GUILayout.EndHorizontal();
                        GUILayout.EndVertical();
                    }
                    GUILayout.EndHorizontal();

                    /*
                     * // Unity won't let us do this
                     * GUILayout.BeginVertical(GUIStyleUtility.ContentEmpty);
                     * OnGUIContentsMaterialInspector(first_material, multiple_materials);
                     * GUILayout.EndVertical();
                     */
                }
                else
                {
                    EditorGUI.BeginChangeCheck();
                    {
                        defaultMaterial = EditorGUILayout.ObjectField(defaultMaterial, typeof(Material), true) as Material;
                    }
                    if (EditorGUI.EndChangeCheck() && defaultMaterial)
                    {
                        CSGSettings.DefaultMaterial = defaultMaterial;
                        CSGSettings.Save();
                    }
                }
            }
            GUILayout.EndVertical();
            EditorGUI.showMixedValue = false;
        }
Exemplo n.º 2
0
        static void OnGUIContents(bool isSceneGUI, ObjectEditBrushTool tool)
        {
            CommonGUI.StartToolGUI();

            var filteredSelection   = CSGBrushEditorManager.FilteredSelection;
            var defaultMoveOffset   = CSGSettings.DefaultMoveOffset;
            var defaultRotateOffset = CSGSettings.DefaultRotateOffset;
            var displayNewCenter    = GridUtility.CleanPosition((Tools.pivotRotation == PivotRotation.Local) ?
                                                                tool.LocalSpacePivotCenter :
                                                                tool.WorldSpacePivotCenter);

            GUILayout.BeginVertical(GUIStyleUtility.ContentEmpty);
            {
                GUILayout.BeginHorizontal(GUIStyleUtility.ContentEmpty);
                {
                    HandleCSGOperations(isSceneGUI, tool, filteredSelection);
                    GUILayout.BeginVertical(GUIStyleUtility.ContentEmpty);
                    {
                        EditorGUI.BeginDisabledGroup(!tool.HaveSelection);
                        {
                            if (Tools.current == Tool.Move)
                            {
                                EditorGUI.BeginDisabledGroup(defaultMoveOffset.sqrMagnitude < MathConstants.EqualityEpsilonSqr);
                                {
                                    if (GUILayout.Button(MoveByOffsetContent))
                                    {
                                        tool.MoveByOffset(RealtimeCSG.CSGSettings.DefaultMoveOffset);
                                    }
                                    TooltipUtility.SetToolTip(MoveByOffsetTooltip);
                                    if (GUILayout.Button(CloneMoveByOffsetContent))
                                    {
                                        tool.CloneMoveByOffset(RealtimeCSG.CSGSettings.DefaultMoveOffset);
                                    }
                                    TooltipUtility.SetToolTip(CloneMoveByOffsetTooltip);
                                }
                                EditorGUI.EndDisabledGroup();
                            }
                            else
                            if (Tools.current == Tool.Rotate)
                            {
                                EditorGUI.BeginDisabledGroup(defaultMoveOffset.sqrMagnitude < MathConstants.EqualityEpsilonSqr);
                                {
                                    if (GUILayout.Button(RotateByOffsetContent))
                                    {
                                        tool.RotateByOffset(Quaternion.Euler(RealtimeCSG.CSGSettings.DefaultRotateOffset));
                                    }
                                    TooltipUtility.SetToolTip(RotateByOffsetTooltip);
                                    if (GUILayout.Button(CloneRotateByOffsetContent))
                                    {
                                        tool.CloneRotateByOffset(Quaternion.Euler(RealtimeCSG.CSGSettings.DefaultRotateOffset));
                                    }
                                    TooltipUtility.SetToolTip(CloneRotateByOffsetTooltip);
                                }
                                EditorGUI.EndDisabledGroup();
                                if (GUILayout.Button(RecenterPivotContent))
                                {
                                    tool.RecenterPivot();
                                }
                                TooltipUtility.SetToolTip(RecenterPivotTooltip);
                            }
                        }
                        EditorGUI.EndDisabledGroup();
                    }
                    GUILayout.EndVertical();
                }
                GUILayout.EndHorizontal();
                GUILayout.Space(5);
                if (Tools.current == Tool.Move)
                {
                    var doubleFieldOptions = isSceneGUI ? MaxWidth150 : GUIStyleUtility.ContentEmpty;
                    EditorGUI.BeginDisabledGroup(!tool.HaveSelection);
                    {
                        EditorGUI.BeginChangeCheck();
                        {
                            GUILayout.Label("Offset");
                            defaultMoveOffset = GUIStyleUtility.DistanceVector3Field(defaultMoveOffset, false, doubleFieldOptions);
                        }
                        if (EditorGUI.EndChangeCheck())
                        {
                            RealtimeCSG.CSGSettings.DefaultMoveOffset = defaultMoveOffset;
                            RealtimeCSG.CSGSettings.Save();
                        }
                    }
                    EditorGUI.EndDisabledGroup();
                }
                else
                if (Tools.current == Tool.Rotate)
                {
                    var doubleFieldOptions = isSceneGUI ? MaxWidth150 : GUIStyleUtility.ContentEmpty;
                    EditorGUI.BeginDisabledGroup(Tools.pivotMode == PivotMode.Center || !tool.HaveSelection);
                    {
                        EditorGUI.BeginChangeCheck();
                        {
                            GUILayout.Label("Offset");
                            defaultRotateOffset = GUIStyleUtility.EulerDegreeField(defaultRotateOffset);
                        }
                        if (EditorGUI.EndChangeCheck())
                        {
                            RealtimeCSG.CSGSettings.DefaultRotateOffset = defaultRotateOffset;
                            RealtimeCSG.CSGSettings.Save();
                        }

                        EditorGUI.BeginChangeCheck();
                        {
                            GUILayout.Label("Pivot");
                            displayNewCenter = GUIStyleUtility.DistanceVector3Field(displayNewCenter, false, doubleFieldOptions);
                            TooltipUtility.SetToolTip(PivotVectorTooltip);
                        }
                        if (EditorGUI.EndChangeCheck())
                        {
                            if (Tools.pivotRotation == PivotRotation.Local)
                            {
                                tool.LocalSpacePivotCenter = displayNewCenter;
                            }
                            else
                            {
                                tool.WorldSpacePivotCenter = displayNewCenter;
                            }
                        }
                    }
                    EditorGUI.EndDisabledGroup();
                }

                /*
                 * if (Tools.current != Tool.Rotate)
                 * {
                 *      if (!isSceneGUI || !SceneView.currentDrawingSceneView.camera.orthographic)
                 *      {
                 *              if (!isSceneGUI)
                 *              {
                 *                      GUILayout.Space(10);
                 *                      GUILayout.Label("Tips", EditorStyles.miniLabel);
                 *              }
                 *
                 *              GUILayout.BeginVertical(isSceneGUI ? GUI.skin.box : GUIStyle.none);
                 *              {
                 *                      GUILayout.Label(Keys.VerticalMoveMode.ToString() + " to drag brush up/down", EditorStyles.miniLabel);
                 *              }
                 *              GUILayout.EndVertical();
                 *      }
                 * }
                 */
            }
            GUILayout.EndVertical();
            EditorGUI.showMixedValue = false;
        }
Exemplo n.º 3
0
        static void OnGUIContents(bool isSceneGUI, ClipBrushTool tool)
        {
            CommonGUI.StartToolGUI();

            if (tool.ClipBrushCount == 0)
            {
                GUILayout.Label(string.Format("no brushes selected", tool.ClipBrushCount), GUIStyleUtility.redTextArea);
            }
            else
            {
                if (tool.ClipBrushCount == 1)
                {
                    GUILayout.Label(string.Format("{0} brush selected", tool.ClipBrushCount));
                }
                else
                {
                    GUILayout.Label(string.Format("{0} brushes selected", tool.ClipBrushCount));
                }
            }
            EditorGUILayout.Space();
            EditorGUI.BeginDisabledGroup(tool == null);
            {
                GUILayout.BeginVertical(isSceneGUI ? GUI.skin.box : GUIStyle.none);
                {
                    var newClipMode = (tool != null) ? tool.clipMode : ((ClipMode)999);
                    var skin        = GUIStyleUtility.Skin;
                    for (int i = 0; i < clipModeValues.Length; i++)
                    {
                        var        selected = newClipMode == clipModeValues[i];
                        GUIContent content;
                        GUIStyle   style;
                        if (selected)
                        {
                            style = GUIStyleUtility.selectedIconLabelStyle;   content = skin.clipNamesOn[i];
                        }
                        else
                        {
                            style = GUIStyleUtility.unselectedIconLabelStyle; content = skin.clipNames[i];
                        }
                        if (GUILayout.Toggle(selected, content, style))
                        {
                            newClipMode = clipModeValues[i];
                        }
                        TooltipUtility.SetToolTip(GUIStyleUtility.clipTooltips[i]);
                    }
                    if (tool != null && tool.clipMode != newClipMode)
                    {
                        tool.SetClipMode(newClipMode);
                    }
                }
                GUILayout.EndVertical();
                if (!isSceneGUI)
                {
                    GUILayout.Space(10);
                }

                bool disabled = (tool == null || tool.editMode != ClipBrushTool.EditMode.EditPoints);

                var defaultMaterial = CSGSettings.DefaultMaterial;
                GUILayout.BeginVertical(isSceneGUI ? MaterialSceneWidth : GUIStyleUtility.ContentEmpty);
                {
                    GUILayout.BeginHorizontal(GUIStyleUtility.ContentEmpty);
                    {
                        if (isSceneGUI)
                        {
                            EditorGUI.BeginChangeCheck();
                            {
                                defaultMaterial = GUIStyleUtility.MaterialImage(defaultMaterial);
                            }
                            if (EditorGUI.EndChangeCheck() && defaultMaterial)
                            {
                                CSGSettings.DefaultMaterial = defaultMaterial;
                                CSGSettings.Save();
                            }
                            GUILayout.BeginVertical(GUIStyleUtility.ContentEmpty);
                        }
                        {
                            EditorGUI.BeginDisabledGroup(disabled);
                            {
                                if (GUILayout.Button(ContentCancel))
                                {
                                    doCancel = true;
                                }
                                TooltipUtility.SetToolTip(CancelTooltip);
                                if (GUILayout.Button(ContentCommit))
                                {
                                    doCommit = true;
                                }
                                TooltipUtility.SetToolTip(CommitTooltip);
                            }
                            EditorGUI.EndDisabledGroup();
                        }
                        if (isSceneGUI)
                        {
                            GUILayout.EndVertical();
                        }
                    }
                    GUILayout.EndHorizontal();
                    if (isSceneGUI)
                    {
                        GUILayout.Space(2);
                        EditorGUI.BeginChangeCheck();
                        {
                            defaultMaterial = EditorGUILayout.ObjectField(defaultMaterial, typeof(Material), true) as Material;
                        }
                        if (EditorGUI.EndChangeCheck() && defaultMaterial)
                        {
                            CSGSettings.DefaultMaterial = defaultMaterial;
                            CSGSettings.Save();
                        }
                    }
                }
                if (!isSceneGUI)
                {
                    EditorGUILayout.Space();
                    GUILayout.BeginHorizontal(GUIStyleUtility.ContentEmpty);
                    {
                        EditorGUILayout.LabelField(ContentDefaultMaterial, largeLabelWidth);
                        GUILayout.BeginVertical(GUIStyleUtility.ContentEmpty);
                        {
                            EditorGUI.BeginChangeCheck();
                            {
                                defaultMaterial = EditorGUILayout.ObjectField(defaultMaterial, typeof(Material), true) as Material;
                            }
                            if (EditorGUI.EndChangeCheck() && defaultMaterial)
                            {
                                CSGSettings.DefaultMaterial = defaultMaterial;
                                CSGSettings.Save();
                            }
                        }
                        GUILayout.Space(2);
                        GUILayout.BeginHorizontal(GUIStyleUtility.ContentEmpty);
                        {
                            GUILayout.Space(5);
                            defaultMaterial = GUIStyleUtility.MaterialImage(defaultMaterial, small: false);
                        }
                        GUILayout.EndHorizontal();
                        GUILayout.EndVertical();
                    }
                    GUILayout.EndHorizontal();

                    /*
                     * // Unity won't let us do this
                     * GUILayout.BeginVertical(GUIStyleUtility.ContentEmpty);
                     * OnGUIContentsMaterialInspector(first_material, multiple_materials);
                     * GUILayout.EndVertical();
                     */
                }
                GUILayout.EndVertical();
            }
            EditorGUI.EndDisabledGroup();
        }
Exemplo n.º 4
0
        static void OnGUIContents(GenerateBrushTool tool, bool isSceneGUI, float height)
        {
            if (!isSceneGUI)
            {
                Rect shapeModeBounds;
                var  csg_skin = GUIStyleUtility.Skin;
                tool.BuilderMode = (ShapeMode)GUIStyleUtility.ToolbarWrapped((int)tool.BuilderMode, ref shapeModeRects, out shapeModeBounds, csg_skin.shapeModeNames, tooltips: GUIStyleUtility.shapeModeTooltips, yOffset: height, areaWidth: EditorGUIUtility.currentViewWidth - 4);
                GUILayout.Space(shapeModeBounds.height);

                CommonGUI.StartToolGUI();

                scrollPos = EditorGUILayout.BeginScrollView(scrollPos);
                {
                    ChooseOperation(tool, isSceneGUI);
                    tool.CurrentGenerator.OnShowGUI(isSceneGUI);
                    CommitOrCancel(isSceneGUI, tool);
                    EditorGUILayout.Space();
                    var defaultMaterial = CSGSettings.DefaultMaterial;
                    GUILayout.BeginHorizontal(GUIStyleUtility.ContentEmpty);
                    {
                        EditorGUILayout.LabelField(ContentDefaultMaterial, largeLabelWidth);
                        GUILayout.BeginVertical(GUIStyleUtility.ContentEmpty);
                        {
                            EditorGUI.BeginChangeCheck();
                            {
                                defaultMaterial = EditorGUILayout.ObjectField(defaultMaterial, typeof(Material), true) as Material;
                            }
                            if (EditorGUI.EndChangeCheck() && defaultMaterial)
                            {
                                CSGSettings.DefaultMaterial = defaultMaterial;
                                tool.CurrentGenerator.OnDefaultMaterialModified();
                                CSGSettings.Save();
                            }
                        }
                        GUILayout.Space(2);
                        GUILayout.BeginHorizontal(GUIStyleUtility.ContentEmpty);
                        {
                            GUILayout.Space(5);
                            EditorGUI.BeginChangeCheck();
                            {
                                defaultMaterial = GUIStyleUtility.MaterialImage(defaultMaterial, small: false);
                            }
                            if (EditorGUI.EndChangeCheck() && defaultMaterial)
                            {
                                CSGSettings.DefaultMaterial = defaultMaterial;
                                tool.CurrentGenerator.OnDefaultMaterialModified();
                                CSGSettings.Save();
                            }
                        }
                        GUILayout.EndHorizontal();
                        GUILayout.EndVertical();
                    }
                    GUILayout.EndHorizontal();

                    /*
                     * // Unity won't let us do this
                     * GUILayout.BeginVertical(GUIStyleUtility.ContentEmpty);
                     * OnGUIContentsMaterialInspector(first_material, multiple_materials);
                     * GUILayout.EndVertical();
                     */
                }
                EditorGUILayout.EndScrollView();
            }
            if (isSceneGUI)
            {
                GUILayout.BeginHorizontal(GUILayout.MinHeight(100));
                {
                    GUILayout.BeginVertical(GUILayout.Width(100));
                    {
                        GUILayout.FlexibleSpace();

                        var rect = GUILayoutUtility.GetLastRect();

                        var  csg_skin = GUIStyleUtility.Skin;
                        Rect shapeModeBounds;
                        tool.BuilderMode = (ShapeMode)GUIStyleUtility.ToolbarWrapped((int)tool.BuilderMode, ref shapeModeRects, out shapeModeBounds, csg_skin.shapeModeNames, tooltips: GUIStyleUtility.shapeModeTooltips, yOffset: rect.y, areaWidth: 100);
                        GUILayout.Space(shapeModeBounds.height);

                        ChooseOperation(tool, isSceneGUI);
                    }
                    GUILayout.EndVertical();
                    GUILayout.BeginVertical(GUIStyleUtility.ContentEmpty);
                    {
                        tool.CurrentGenerator.OnShowGUI(isSceneGUI);
                        GUILayout.FlexibleSpace();
                        CommitOrCancel(isSceneGUI, tool);
                    }
                    GUILayout.EndVertical();
                }
                GUILayout.EndHorizontal();
            }
        }