コード例 #1
0
        /*
         * static void OnGUIContentsMaterialInspector(Material material, bool mixedValues)
         * {
         *      //if (materialEditor == null || prevMaterial != material)
         *      {
         *              var editor = materialEditor as Editor;
         *              Editor.CreateCachedEditor(material, typeof(MaterialEditor), ref editor);
         *              materialEditor = editor as MaterialEditor;
         *      }
         *
         *      if (materialEditor != null)
         *      {
         *              EditorGUI.showMixedValue = mixedValues;
         *              try
         *              {
         *                      materialEditor.DrawHeader();
         *                      if (materialEditor.PropertiesGUI())
         *                      {
         *                              materialEditor.PropertiesChanged();
         *                      }
         *              }
         *              catch
         *              {}
         *              EditorGUI.showMixedValue = false;
         *      }
         * }
         */

        private static void OnGUIContents(bool isSceneGUI, EditModeSurface tool)
        {
            EditModeCommonGUI.StartToolGUI();

            var selectedBrushSurfaces = (tool == null) ? new SelectedBrushSurface[0] : tool.GetSelectedSurfaces();
            var enabled = selectedBrushSurfaces.Length > 0;

            EditorGUI.BeginDisabledGroup(!enabled);
            {
                Material material      = null;
                var      currentTexGen = new TexGen();

                var  haveTexgen            = false;
                var  multipleColors        = !enabled;
                var  multipleTranslationX  = !enabled;
                var  multipleTranslationY  = !enabled;
                var  multipleScaleX        = !enabled;
                var  multipleScaleY        = !enabled;
                var  multipleRotationAngle = !enabled;
                var  multipleMaterials     = !enabled;
                bool?textureLocked         = null;

                bool foundHelperMaterial = false;
                RenderSurfaceType?firstRenderSurfaceType = null;
                Material          firstMaterial          = null;
                if (selectedBrushSurfaces.Length > 0)
                {
                    for (var i = 0; i < selectedBrushSurfaces.Length; i++)
                    {
                        var brush = selectedBrushSurfaces[i].brush;
                        if (!brush)
                        {
                            continue;
                        }
                        var surfaceIndex = selectedBrushSurfaces[i].surfaceIndex;
                        if (surfaceIndex >= brush.Shape.Surfaces.Length)
                        {
                            Debug.LogWarning("surface_index >= brush.Shape.Surfaces.Length");
                            continue;
                        }
                        var texGenIndex = brush.Shape.Surfaces[surfaceIndex].TexGenIndex;
                        if (texGenIndex >= brush.Shape.TexGens.Length)
                        {
                            Debug.LogWarning("texGen_index >= brush.Shape.TexGens.Length");
                            continue;
                        }
                        var      brushCache = InternalCSGModelManager.GetBrushCache(brush);
                        var      model      = (brushCache != null) ? brushCache.childData.Model : null;
                        Material foundMaterial;
                        var      texGenFlags = brush.Shape.TexGenFlags[texGenIndex];
                        if (model && (!model.IsRenderable || model.ShadowsOnly))
                        {
                            foundHelperMaterial = true;
                            if (!firstRenderSurfaceType.HasValue)
                            {
                                firstRenderSurfaceType = ModelTraits.GetModelSurfaceType(model);
                            }
                            foundMaterial = null;
                        }
                        else
                        if ((texGenFlags & TexGenFlags.NoRender) == TexGenFlags.NoRender)
                        {
                            foundHelperMaterial = true;
                            if (!firstRenderSurfaceType.HasValue)
                            {
                                if ((texGenFlags & TexGenFlags.NoCastShadows) != TexGenFlags.NoCastShadows)
                                {
                                    firstRenderSurfaceType = RenderSurfaceType.ShadowOnly;
                                }
                                else
                                if ((texGenFlags & TexGenFlags.NoCollision) != TexGenFlags.NoCollision)
                                {
                                    firstRenderSurfaceType = RenderSurfaceType.Collider;
                                }
                                else
                                {
                                    firstRenderSurfaceType = RenderSurfaceType.Hidden;
                                }
                            }
                            foundMaterial = null;
                        }
                        else
                        {
                            var surfaceMaterial = brush.Shape.TexGens[texGenIndex].RenderMaterial;
                            if (!foundHelperMaterial)
                            {
                                var surfaceType = MaterialUtility.GetMaterialSurfaceType(surfaceMaterial);
                                if (!firstRenderSurfaceType.HasValue)
                                {
                                    firstRenderSurfaceType = surfaceType;
                                }
                                foundHelperMaterial = surfaceType != RenderSurfaceType.Normal;
                            }
                            foundMaterial = surfaceMaterial;
                        }
                        if ((texGenFlags & TexGenFlags.WorldSpaceTexture) == TexGenFlags.WorldSpaceTexture)
                        {
                            if (i == 0)
                            {
                                textureLocked = false;
                            }
                            else if (textureLocked.HasValue && textureLocked.Value)
                            {
                                textureLocked = null;
                            }
                        }
                        else
                        {
                            if (i == 0)
                            {
                                textureLocked = true;
                            }
                            else if (textureLocked.HasValue && !textureLocked.Value)
                            {
                                textureLocked = null;
                            }
                        }
                        if (foundMaterial != material)
                        {
                            if (!material)
                            {
                                firstMaterial = foundMaterial;
                                material      = foundMaterial;
                            }
                            else
                            {
                                multipleMaterials = true;
                            }
                        }
                        if (!haveTexgen)
                        {
                            currentTexGen = brush.Shape.TexGens[texGenIndex];
                            haveTexgen    = true;
                        }
                        else
                        {
                            if (!multipleColors)
                            {
                                var color = brush.Shape.TexGens[texGenIndex].Color;
                                multipleColors = currentTexGen.Color.a != color.a ||
                                                 currentTexGen.Color.b != color.b ||
                                                 currentTexGen.Color.g != color.g ||
                                                 currentTexGen.Color.r != color.r;
                            }
                            if (!multipleScaleX || !multipleScaleY)
                            {
                                var scale = brush.Shape.TexGens[texGenIndex].Scale;
                                multipleScaleX = multipleScaleX || currentTexGen.Scale.x != scale.x;
                                multipleScaleY = multipleScaleY || currentTexGen.Scale.y != scale.y;
                            }

                            if (!multipleTranslationX || !multipleTranslationY)
                            {
                                var translation = brush.Shape.TexGens[texGenIndex].Translation;
                                multipleTranslationX = multipleTranslationX || currentTexGen.Translation.x != translation.x;
                                multipleTranslationY = multipleTranslationY || currentTexGen.Translation.y != translation.y;
                            }

                            if (!multipleRotationAngle)
                            {
                                var rotationAngle = brush.Shape.TexGens[texGenIndex].RotationAngle;
                                multipleRotationAngle = currentTexGen.RotationAngle != rotationAngle;
                            }
                        }
                    }
                    if (foundHelperMaterial && !firstMaterial)
                    {
                        if (firstRenderSurfaceType.HasValue)
                        {
                            firstMaterial = MaterialUtility.GetSurfaceMaterial(firstRenderSurfaceType.Value);
                        }
                        else
                        {
                            firstMaterial = MaterialUtility.HiddenMaterial;
                        }
                    }
                }

                GUILayout.BeginVertical(isSceneGUI ? materialDoubleWidth : CSG_GUIStyleUtility.ContentEmpty);
                {
                    GUILayout.BeginVertical(isSceneGUI ? GUI.skin.box : GUIStyle.none);
                    {
                        /*
                         * Color new_color;
                         * EditorGUI.BeginChangeCheck();
                         * {
                         *      EditorGUI.showMixedValue = multipleColors;
                         *      // why doesn't the colorfield return a modified color?
                         *      try
                         *      {
                         *              new_color = EditorGUILayout.ColorField(GUIContent.none, currentTexGen.Color);
                         *      }
                         *      catch
                         *      {
                         *              new_color = currentTexGen.Color;
                         *      }
                         * }
                         * if (EditorGUI.EndChangeCheck() || currentTexGen.Color != new_color)
                         * {
                         *      SurfaceUtility.SetColors(selectedBrushSurfaces, new_color);
                         * }
                         */
                        if (isSceneGUI)
                        {
                            GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty);
                            {
                                EditorGUI.BeginDisabledGroup(material == null);
                                {
                                    GUILayout.BeginVertical(CSG_GUIStyleUtility.ContentEmpty);
                                    {
                                        GUILayout.Space(1);

                                        /*
                                         * Color new_color;
                                         * EditorGUI.BeginChangeCheck();
                                         * {
                                         *      EditorGUI.showMixedValue = multipleColors;
                                         *      // why doesn't the colorfield return a modified color?
                                         *      try
                                         *      {
                                         *              new_color = EditorGUILayout.ColorField(GUIContent.none, currentTexGen.Color);
                                         *      }
                                         *      catch
                                         *      {
                                         *              new_color = currentTexGen.Color;
                                         *      }
                                         * }
                                         * if (EditorGUI.EndChangeCheck() || currentTexGen.Color != new_color)
                                         * {
                                         *      SurfaceUtility.SetColors(selectedBrushSurfaces, new_color);
                                         * }
                                         *
                                         * GUILayout.Space(1);
                                         */
                                        Material newMaterial;
                                        EditorGUI.BeginChangeCheck();
                                        {
                                            EditorGUI.showMixedValue = multipleMaterials;
                                            newMaterial = EditorGUILayout.ObjectField(material, typeof(Material), true) as Material;
                                            EditorGUI.showMixedValue = false;
                                        }
                                        if (EditorGUI.EndChangeCheck())
                                        {
                                            if (newMaterial)
                                            {
                                                SurfaceUtility.SetMaterials(selectedBrushSurfaces, newMaterial);
                                                CSGSettings.DefaultMaterial = newMaterial;
                                                CSGSettings.Save();
                                            }
                                        }
                                    }
                                    GUILayout.EndVertical();
                                    GUILayout.Space(1);
                                }
                                EditorGUI.EndDisabledGroup();
                            }
                            GUILayout.EndHorizontal();
                            GUILayout.Space(4);
                            GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty);
                            {
                                GUILayout.Space(2);
                                OnGUIContentsMaterialImage(isSceneGUI, firstMaterial, multipleMaterials, selectedBrushSurfaces);
                                GUILayout.BeginHorizontal(materialWidth);
                                {
                                    GUILayout.FlexibleSpace();
                                    GUILayout.BeginVertical(materialHeight);
                                    {
                                        OnGUIContentsJustify(isSceneGUI, selectedBrushSurfaces);
                                        GUILayout.FlexibleSpace();
                                    }
                                    GUILayout.EndVertical();
                                }
                                GUILayout.EndHorizontal();
                                GUILayout.FlexibleSpace();
                            }
                            GUILayout.EndHorizontal();
                        }
                    }
                    GUILayout.EndVertical();

                    if (!isSceneGUI)
                    {
                        EditorGUILayout.Space();
                    }

                    if (currentTexGen.Scale.x == 0.0f)
                    {
                        currentTexGen.Scale.x = 1.0f;
                    }
                    if (currentTexGen.Scale.y == 0.0f)
                    {
                        currentTexGen.Scale.y = 1.0f;
                    }

                    const float scale_round = 10000.0f;
                    currentTexGen.Scale.x       = Mathf.RoundToInt(currentTexGen.Scale.x * scale_round) / scale_round;
                    currentTexGen.Scale.y       = Mathf.RoundToInt(currentTexGen.Scale.y * scale_round) / scale_round;
                    currentTexGen.Translation.x = Mathf.RoundToInt(currentTexGen.Translation.x * scale_round) / scale_round;
                    currentTexGen.Translation.y = Mathf.RoundToInt(currentTexGen.Translation.y * scale_round) / scale_round;
                    currentTexGen.RotationAngle = Mathf.RoundToInt(currentTexGen.RotationAngle * scale_round) / scale_round;

                    var leftStyle   = isSceneGUI ? EditorStyles.miniButtonLeft  : GUI.skin.button;
                    var middleStyle = isSceneGUI ? EditorStyles.miniButtonMid   : GUI.skin.button;
                    var rightStyle  = isSceneGUI ? EditorStyles.miniButtonRight : GUI.skin.button;

                    GUILayout.BeginVertical(isSceneGUI ? GUI.skin.box : GUIStyle.none);
                    {
                        EditorGUI.BeginChangeCheck();
                        {
                            EditorGUI.showMixedValue = !textureLocked.HasValue;
                            textureLocked            = EditorGUILayout.ToggleLeft(ContentLockTexture, textureLocked.HasValue ? textureLocked.Value : false);
                            TooltipUtility.SetToolTip(ToolTipLockTexture);
                        }
                        if (EditorGUI.EndChangeCheck())
                        {
                            SurfaceUtility.SetTextureLock(selectedBrushSurfaces, textureLocked.Value);
                        }
                    }
                    GUILayout.EndVertical();

                    GUILayout.BeginVertical(isSceneGUI ? GUI.skin.box : GUIStyle.none);
                    {
                        GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty);
                        {
                            if (isSceneGUI)
                            {
                                EditorGUILayout.LabelField(ContentUVScale, EditorStyles.miniLabel, labelWidth);
                            }
                            else
                            {
                                EditorGUILayout.LabelField(ContentUVScale, largeLabelWidth);
                            }
                            TooltipUtility.SetToolTip(ToolTipScaleUV);

                            GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty);
                            {
                                if (!isSceneGUI)
                                {
                                    EditorGUILayout.LabelField(ContentUSymbol, unitWidth);
                                }
                                EditorGUI.BeginChangeCheck();
                                {
                                    EditorGUI.showMixedValue = multipleScaleX;
                                    currentTexGen.Scale.x    = EditorGUILayout.FloatField(currentTexGen.Scale.x, minFloatFieldWidth);
                                }
                                if (EditorGUI.EndChangeCheck())
                                {
                                    SurfaceUtility.SetScaleX(selectedBrushSurfaces, currentTexGen.Scale.x);
                                }
                                if (!isSceneGUI)
                                {
                                    EditorGUILayout.LabelField(ContentVSymbol, unitWidth);
                                }
                                EditorGUI.BeginChangeCheck();
                                {
                                    EditorGUI.showMixedValue = multipleScaleY;
                                    currentTexGen.Scale.y    = EditorGUILayout.FloatField(currentTexGen.Scale.y, minFloatFieldWidth);
                                }
                                if (EditorGUI.EndChangeCheck())
                                {
                                    SurfaceUtility.SetScaleY(selectedBrushSurfaces, currentTexGen.Scale.y);
                                }
                            }
                            GUILayout.EndHorizontal();
                        }
                        GUILayout.EndHorizontal();
                        GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty);
                        {
                            if (isSceneGUI)
                            {
                                EditorGUILayout.LabelField(ContentOffset, EditorStyles.miniLabel, labelWidth);
                            }
                            else
                            {
                                EditorGUILayout.LabelField(ContentOffset, largeLabelWidth);
                            }
                            TooltipUtility.SetToolTip(ToolTipOffsetUV);

                            GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty);
                            {
                                if (!isSceneGUI)
                                {
                                    EditorGUILayout.LabelField(ContentUSymbol, unitWidth);
                                }
                                EditorGUI.BeginChangeCheck();
                                {
                                    EditorGUI.showMixedValue    = multipleTranslationX;
                                    currentTexGen.Translation.x = EditorGUILayout.FloatField(currentTexGen.Translation.x, minFloatFieldWidth);
                                }
                                if (EditorGUI.EndChangeCheck())
                                {
                                    SurfaceUtility.SetTranslationX(selectedBrushSurfaces, currentTexGen.Translation.x);
                                }

                                if (!isSceneGUI)
                                {
                                    EditorGUILayout.LabelField(ContentVSymbol, unitWidth);
                                }
                                EditorGUI.BeginChangeCheck();
                                {
                                    EditorGUI.showMixedValue    = multipleTranslationY;
                                    currentTexGen.Translation.y = EditorGUILayout.FloatField(currentTexGen.Translation.y, minFloatFieldWidth);
                                }
                                if (EditorGUI.EndChangeCheck())
                                {
                                    SurfaceUtility.SetTranslationY(selectedBrushSurfaces, currentTexGen.Translation.y);
                                }
                            }
                            GUILayout.EndHorizontal();
                        }
                        GUILayout.EndHorizontal();
                        GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty);
                        {
                            if (isSceneGUI)
                            {
                                EditorGUILayout.LabelField(ContentRotate, EditorStyles.miniLabel, labelWidth);
                            }
                            else
                            {
                                EditorGUILayout.LabelField(ContentRotate, largeLabelWidth);
                            }
                            TooltipUtility.SetToolTip(ToolTipRotation);

                            if (!isSceneGUI)
                            {
                                GUILayout.BeginVertical(CSG_GUIStyleUtility.ContentEmpty);
                            }

                            GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty);
                            {
                                EditorGUI.BeginChangeCheck();
                                {
                                    EditorGUI.showMixedValue    = multipleRotationAngle;
                                    currentTexGen.RotationAngle = EditorGUILayout.FloatField(currentTexGen.RotationAngle, minFloatFieldWidth);
                                    if (!isSceneGUI)
                                    {
                                        EditorGUILayout.LabelField(ContentAngleSymbol, unitWidth);
                                    }
                                }
                                if (EditorGUI.EndChangeCheck())
                                {
                                    SurfaceUtility.SetRotationAngle(selectedBrushSurfaces, currentTexGen.RotationAngle);
                                }
                            }
                            GUILayout.EndHorizontal();

                            var buttonWidth = isSceneGUI ? new GUILayoutOption[] { angleButtonWidth } : new GUILayoutOption[0];
                            GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty);
                            {
                                if (GUILayout.Button(ContentRotate90Negative, leftStyle, buttonWidth))
                                {
                                    SurfaceUtility.AddRotationAngle(selectedBrushSurfaces, -90.0f);
                                }
                                TooltipUtility.SetToolTip(ToolTipRotate90Negative);
                                if (GUILayout.Button(ContentRotate90Positive, rightStyle, buttonWidth))
                                {
                                    SurfaceUtility.AddRotationAngle(selectedBrushSurfaces, +90.0f);
                                }
                                TooltipUtility.SetToolTip(ToolTipRotate90Positive);
                            }
                            GUILayout.EndHorizontal();
                            if (!isSceneGUI)
                            {
                                GUILayout.EndVertical();
                            }
                        }
                        GUILayout.EndHorizontal();
                    }
                    GUILayout.EndVertical();

                    if (!isSceneGUI)
                    {
                        EditorGUILayout.Space();
                    }

                    GUILayout.BeginVertical(isSceneGUI ? GUI.skin.box : GUIStyle.none);
                    {
                        GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty);
                        {
                            if (!isSceneGUI)
                            {
                                GUILayout.Label(ContentFit, largeLabelWidth);
                            }
                            else
                            {
                                GUILayout.Label(ContentFit, EditorStyles.miniLabel, smallLabelWidth);
                            }
                            if (GUILayout.Button(ContentFitX, leftStyle))
                            {
                                SurfaceUtility.FitSurfaceX(selectedBrushSurfaces);
                            }
                            TooltipUtility.SetToolTip(ToolTipFitX);
                            if (GUILayout.Button(ContentFitXY, middleStyle))
                            {
                                SurfaceUtility.FitSurface(selectedBrushSurfaces);
                            }
                            TooltipUtility.SetToolTip(ToolTipFitXY);
                            if (GUILayout.Button(ContentFitY, rightStyle))
                            {
                                SurfaceUtility.FitSurfaceY(selectedBrushSurfaces);
                            }
                            TooltipUtility.SetToolTip(ToolTipFitY);
                        }
                        GUILayout.EndHorizontal();
                        GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty);
                        {
                            if (!isSceneGUI)
                            {
                                GUILayout.Label(ContentReset, largeLabelWidth);
                            }
                            else
                            {
                                GUILayout.Label(ContentReset, EditorStyles.miniLabel, smallLabelWidth);
                            }
                            if (GUILayout.Button(ContentResetX, leftStyle))
                            {
                                SurfaceUtility.ResetSurfaceX(selectedBrushSurfaces);
                            }
                            TooltipUtility.SetToolTip(ToolTipResetX);
                            if (GUILayout.Button(ContentResetXY, middleStyle))
                            {
                                SurfaceUtility.ResetSurface(selectedBrushSurfaces);
                            }
                            TooltipUtility.SetToolTip(ToolTipResetXY);
                            if (GUILayout.Button(ContentResetY, rightStyle))
                            {
                                SurfaceUtility.ResetSurfaceY(selectedBrushSurfaces);
                            }
                            TooltipUtility.SetToolTip(ToolTipResetY);
                        }
                        GUILayout.EndHorizontal();
                        GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty);
                        {
                            if (!isSceneGUI)
                            {
                                GUILayout.Label(ContentFlip, largeLabelWidth);
                            }
                            else
                            {
                                GUILayout.Label(ContentFlip, EditorStyles.miniLabel, smallLabelWidth);
                            }
                            if (GUILayout.Button(ContentFlipX, leftStyle))
                            {
                                SurfaceUtility.FlipX(selectedBrushSurfaces);
                            }
                            TooltipUtility.SetToolTip(ToolTipFlipX);
                            if (GUILayout.Button(ContentFlipXY, middleStyle))
                            {
                                SurfaceUtility.FlipXY(selectedBrushSurfaces);
                            }
                            TooltipUtility.SetToolTip(ToolTipFlipXY);
                            if (GUILayout.Button(ContentFlipY, rightStyle))
                            {
                                SurfaceUtility.FlipY(selectedBrushSurfaces);
                            }
                            TooltipUtility.SetToolTip(ToolTipFlipY);
                        }
                        GUILayout.EndHorizontal();
                        GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty);
                        {
                            if (!isSceneGUI)
                            {
                                GUILayout.Label(ContentScale, largeLabelWidth);
                            }
                            else
                            {
                                GUILayout.Label(ContentScale, EditorStyles.miniLabel, smallLabelWidth);
                            }
                            if (GUILayout.Button(ContentDoubleScale, leftStyle))
                            {
                                SurfaceUtility.MultiplyScale(selectedBrushSurfaces, 2.0f);
                            }
                            TooltipUtility.SetToolTip(ToolTipDoubleScale);
                            if (GUILayout.Button(ContentHalfScale, rightStyle))
                            {
                                SurfaceUtility.MultiplyScale(selectedBrushSurfaces, 0.5f);
                            }
                            TooltipUtility.SetToolTip(ToolTipHalfScale);
                        }
                        GUILayout.EndHorizontal();
                    }
                    GUILayout.EndVertical();

                    if (!isSceneGUI)
                    {
                        EditorGUILayout.Space();
                    }

                    if (!isSceneGUI)
                    {
                        OnGUIContentsJustify(isSceneGUI, selectedBrushSurfaces);
                    }

                    if (!isSceneGUI)
                    {
                        EditorGUILayout.Space();
                    }

                    GUILayout.BeginVertical(isSceneGUI ? GUI.skin.box : GUIStyle.none);
                    {
                        EditModeCommonGUI.OnSurfaceFlagButtons(selectedBrushSurfaces, isSceneGUI);
                        GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty);
                        {
                            EditorGUI.BeginDisabledGroup(!SurfaceUtility.CanSmooth(selectedBrushSurfaces));
                            {
                                if (GUILayout.Button(ContentSmoothSurfaces, leftStyle))
                                {
                                    SurfaceUtility.Smooth(selectedBrushSurfaces);
                                }
                                TooltipUtility.SetToolTip(ToolTipSmoothSurfaces);
                            }
                            EditorGUI.EndDisabledGroup();
                            EditorGUI.BeginDisabledGroup(!SurfaceUtility.CanUnSmooth(selectedBrushSurfaces));
                            {
                                if (GUILayout.Button(ContentUnSmoothSurfaces, rightStyle))
                                {
                                    SurfaceUtility.UnSmooth(selectedBrushSurfaces);
                                }
                                TooltipUtility.SetToolTip(ToolTipUnSmoothSurfaces);
                            }
                            EditorGUI.EndDisabledGroup();
                        }
                        GUILayout.EndHorizontal();
                    }
                    GUILayout.EndVertical();

                    if (!isSceneGUI)
                    {
                        EditorGUILayout.Space();
                        Material new_material;
                        GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty);
                        {
                            EditorGUILayout.LabelField(ContentMaterial, largeLabelWidth);
                            GUILayout.BeginVertical(CSG_GUIStyleUtility.ContentEmpty);
                            {
                                EditorGUI.BeginChangeCheck();
                                {
                                    EditorGUI.showMixedValue = multipleMaterials;
                                    new_material             = EditorGUILayout.ObjectField(material, typeof(Material), true) as Material;
                                    EditorGUI.showMixedValue = false;
                                }
                                if (EditorGUI.EndChangeCheck())
                                {
                                    if (!new_material)
                                    {
                                        new_material = MaterialUtility.MissingMaterial;
                                    }
                                    SurfaceUtility.SetMaterials(selectedBrushSurfaces, new_material);
                                }
                            }
                            GUILayout.Space(2);
                            GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty);
                            {
                                GUILayout.Space(5);
                                OnGUIContentsMaterialImage(isSceneGUI, firstMaterial, multipleMaterials, selectedBrushSurfaces);
                            }
                            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();
            EditorGUI.showMixedValue = false;
        }