static void OnGUIContents(bool isSceneGUI, EditModePlace tool) { EditModeCommonGUI.StartToolGUI(); var filteredSelection = EditModeManager.FilteredSelection; var defaultMoveOffset = CSGSettings.DefaultMoveOffset; var defaultRotateOffset = CSGSettings.DefaultRotateOffset; var displayNewCenter = GridUtility.CleanPosition((Tools.pivotRotation == PivotRotation.Local) ? tool.LocalSpacePivotCenter : tool.WorldSpacePivotCenter); GUILayout.BeginVertical(CSG_GUIStyleUtility.ContentEmpty); { GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty); { ShowCSGOperations(isSceneGUI, tool, filteredSelection); GUILayout.BeginVertical(CSG_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 : CSG_GUIStyleUtility.ContentEmpty; EditorGUI.BeginDisabledGroup(!tool.HaveSelection); { EditorGUI.BeginChangeCheck(); { GUILayout.Label(MoveOffsetContent); defaultMoveOffset = CSG_EditorGUIUtility.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 : CSG_GUIStyleUtility.ContentEmpty; EditorGUI.BeginDisabledGroup(Tools.pivotMode == PivotMode.Center || !tool.HaveSelection); { EditorGUI.BeginChangeCheck(); { GUILayout.Label(RotationCenterContent); defaultRotateOffset = CSG_EditorGUIUtility.EulerDegreeField(defaultRotateOffset); } if (EditorGUI.EndChangeCheck()) { RealtimeCSG.CSGSettings.DefaultRotateOffset = defaultRotateOffset; RealtimeCSG.CSGSettings.Save(); } EditorGUI.BeginChangeCheck(); { GUILayout.Label(PivotCenterContent); displayNewCenter = CSG_EditorGUIUtility.DistanceVector3Field(displayNewCenter, false, doubleFieldOptions); TooltipUtility.SetToolTip(PivotVectorTooltip); } if (EditorGUI.EndChangeCheck()) { if (Tools.pivotRotation == PivotRotation.Local) { tool.LocalSpacePivotCenter = displayNewCenter; } else { tool.WorldSpacePivotCenter = displayNewCenter; } } } EditorGUI.EndDisabledGroup(); } } GUILayout.EndVertical(); EditorGUI.showMixedValue = false; }
static void OnGUIContents(bool isSceneGUI, EditModeClip tool) { EditModeCommonGUI.StartToolGUI(); if (tool.ClipBrushCount == 0) { GUILayout.Label(string.Format("no brushes selected", tool.ClipBrushCount), CSG_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 = CSG_GUIStyleUtility.Skin; for (int i = 0; i < clipModeValues.Length; i++) { var selected = newClipMode == clipModeValues[i]; GUIContent content; GUIStyle style; if (selected) { style = CSG_GUIStyleUtility.selectedIconLabelStyle; content = skin.clipNamesOn[i]; } else { style = CSG_GUIStyleUtility.unselectedIconLabelStyle; content = skin.clipNames[i]; } if (GUILayout.Toggle(selected, content, style)) { newClipMode = clipModeValues[i]; } TooltipUtility.SetToolTip(CSG_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 != EditModeClip.EditMode.EditPoints); var defaultMaterial = CSGSettings.DefaultMaterial; GUILayout.BeginVertical(isSceneGUI ? MaterialSceneWidth : CSG_GUIStyleUtility.ContentEmpty); { GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty); { if (isSceneGUI) { EditorGUI.BeginChangeCheck(); { defaultMaterial = CSG_EditorGUIUtility.MaterialImage(defaultMaterial); } if (EditorGUI.EndChangeCheck() && defaultMaterial) { CSGSettings.DefaultMaterial = defaultMaterial; CSGSettings.Save(); } GUILayout.BeginVertical(CSG_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(CSG_GUIStyleUtility.ContentEmpty); { EditorGUILayout.LabelField(ContentDefaultMaterial, largeLabelWidth); GUILayout.BeginVertical(CSG_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(CSG_GUIStyleUtility.ContentEmpty); { GUILayout.Space(5); defaultMaterial = CSG_EditorGUIUtility.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(); }
/* * 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();*/ static void OnGUIContents(bool isSceneGUI, EditModeMeshEdit tool) { EditModeCommonGUI.StartToolGUI(); var filteredSelection = EditModeManager.FilteredSelection; var left = EditorStyles.miniButtonLeft; var middle = EditorStyles.miniButtonMid; var right = EditorStyles.miniButtonRight; var button = GUI.skin.button; var defaultMaterial = CSGSettings.DefaultMaterial; GUILayout.BeginVertical(isSceneGUI ? InSceneWidth : CSG_GUIStyleUtility.ContentEmpty); { ShowCSGOperations(isSceneGUI, tool, filteredSelection); GUILayout.BeginVertical(isSceneGUI ? GUI.skin.box : GUIStyle.none); { var selectionIgnoreBackfaced = CSGSettings.HiddenSurfacesNotSelectable; var selectionVertex = CSGSettings.SelectionVertex; var selectionEdge = CSGSettings.SelectionEdge; var selectionSurface = CSGSettings.SelectionSurface; EditorGUILayout.LabelField(ContentSelection); EditorGUI.BeginChangeCheck(); { GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty); { selectionIgnoreBackfaced = GUILayout.Toggle(selectionIgnoreBackfaced, ContentIgnoreHidden, button); TooltipUtility.SetToolTip(TooltipIgnoreHidden); } GUILayout.EndHorizontal(); if (!selectionVertex && !selectionEdge && !selectionSurface) { GUILayout.Label("No selection mode has been selected and nothing can be selected", CSG_GUIStyleUtility.redTextArea); } GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty); { selectionVertex = GUILayout.Toggle(selectionVertex, ContentVertex, button); TooltipUtility.SetToolTip(TooltipVertex); selectionEdge = GUILayout.Toggle(selectionEdge, ContentEdge, button); TooltipUtility.SetToolTip(TooltipEdge); selectionSurface = GUILayout.Toggle(selectionSurface, ContentSurface, button); TooltipUtility.SetToolTip(TooltipSurface); } GUILayout.EndHorizontal(); } if (EditorGUI.EndChangeCheck()) { CSGSettings.HiddenSurfacesNotSelectable = selectionIgnoreBackfaced; CSGSettings.SelectionVertex = selectionVertex; CSGSettings.SelectionEdge = selectionEdge; CSGSettings.SelectionSurface = selectionSurface; CSGSettings.Save(); } GUILayout.Space(3); } GUILayout.EndVertical(); GUILayout.BeginVertical(isSceneGUI ? GUI.skin.box : GUIStyle.none); { var autoCommitExtrusion = CSGSettings.AutoCommitExtrusion; EditorGUI.BeginChangeCheck(); { autoCommitExtrusion = GUILayout.Toggle(autoCommitExtrusion, ContentAutoCommitExtrusion, button); TooltipUtility.SetToolTip(TooltipAutoCommitExtrusion); } if (EditorGUI.EndChangeCheck()) { CSGSettings.AutoCommitExtrusion = autoCommitExtrusion; CSGSettings.Save(); } } GUILayout.EndVertical(); GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty); { if (isSceneGUI) { GUILayout.Space(4); GUILayout.BeginVertical(CSG_GUIStyleUtility.ContentEmpty); { EditorGUI.BeginChangeCheck(); { defaultMaterial = CSG_EditorGUIUtility.MaterialImage(defaultMaterial, small: true); } if (EditorGUI.EndChangeCheck() && defaultMaterial) { CSGSettings.DefaultMaterial = defaultMaterial; CSGSettings.Save(); } } GUILayout.EndVertical(); } bool have_nodes = tool != null && (filteredSelection.NodeTargets.Length > 0); GUILayout.BeginVertical(CSG_GUIStyleUtility.ContentEmpty); { EditorGUI.BeginDisabledGroup(!have_nodes); { GUILayout.BeginHorizontal(CSG_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(Camera.current); } TooltipUtility.SetToolTip(TooltipSnapToGrid); } EditorGUI.EndDisabledGroup(); } GUILayout.EndVertical(); } GUILayout.EndHorizontal(); GUILayout.Space(2); if (!isSceneGUI) { EditorGUILayout.Space(); GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty); { EditorGUILayout.LabelField(ContentDefaultMaterial, largeLabelWidth); GUILayout.BeginVertical(CSG_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(CSG_GUIStyleUtility.ContentEmpty); { GUILayout.Space(5); defaultMaterial = CSG_EditorGUIUtility.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; }
/* * 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; }
static void OnGUIContents(EditModeGenerate tool, bool isSceneGUI, float height) { if (!isSceneGUI) { Rect shapeModeBounds; var csg_skin = CSG_GUIStyleUtility.Skin; tool.BuilderMode = (ShapeMode)CSG_EditorGUIUtility.ToolbarWrapped((int)tool.BuilderMode, ref shapeModeRects, out shapeModeBounds, csg_skin.shapeModeNames, tooltips: CSG_GUIStyleUtility.shapeModeTooltips, yOffset: height, areaWidth: EditorGUIUtility.currentViewWidth - 4); GUILayout.Space(shapeModeBounds.height); EditModeCommonGUI.StartToolGUI(); scrollPos = EditorGUILayout.BeginScrollView(scrollPos); { ChooseOperation(tool, isSceneGUI); tool.CurrentGenerator.OnShowGUI(isSceneGUI); CommitOrCancel(isSceneGUI, tool); EditorGUILayout.Space(); var defaultMaterial = CSGSettings.DefaultMaterial; GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty); { EditorGUILayout.LabelField(ContentDefaultMaterial, largeLabelWidth); GUILayout.BeginVertical(CSG_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(CSG_GUIStyleUtility.ContentEmpty); { GUILayout.Space(5); EditorGUI.BeginChangeCheck(); { defaultMaterial = CSG_EditorGUIUtility.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 = CSG_GUIStyleUtility.Skin; Rect shapeModeBounds; tool.BuilderMode = (ShapeMode)CSG_EditorGUIUtility.ToolbarWrapped((int)tool.BuilderMode, ref shapeModeRects, out shapeModeBounds, csg_skin.shapeModeNames, tooltips: CSG_GUIStyleUtility.shapeModeTooltips, yOffset: rect.y, xOffset: rect.x, areaWidth: 100); GUILayout.Space(shapeModeBounds.height); ChooseOperation(tool, isSceneGUI); } GUILayout.EndVertical(); GUILayout.BeginVertical(CSG_GUIStyleUtility.ContentEmpty); { tool.CurrentGenerator.OnShowGUI(isSceneGUI); GUILayout.FlexibleSpace(); CommitOrCancel(isSceneGUI, tool); } GUILayout.EndVertical(); } GUILayout.EndHorizontal(); } }
static void OnGUIContents(bool isSceneGUI, EditModeMeshEdit tool) { EditModeCommonGUI.StartToolGUI(); var filteredSelection = EditModeManager.FilteredSelection; var defaultMaterial = CSGSettings.DefaultMaterial; GUILayout.BeginVertical(isSceneGUI ? InSceneWidth : CSG_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(CSG_GUIStyleUtility.ContentEmpty); { if (isSceneGUI) { GUILayout.BeginVertical(CSG_GUIStyleUtility.ContentEmpty); { EditorGUI.BeginChangeCheck(); { defaultMaterial = CSG_EditorGUIUtility.MaterialImage(defaultMaterial, small: true); } if (EditorGUI.EndChangeCheck() && defaultMaterial) { CSGSettings.DefaultMaterial = defaultMaterial; CSGSettings.Save(); } } GUILayout.EndVertical(); } GUILayout.BeginVertical(CSG_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(CSG_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(CSG_GUIStyleUtility.ContentEmpty); { EditorGUILayout.LabelField(ContentDefaultMaterial, largeLabelWidth); GUILayout.BeginVertical(CSG_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(CSG_GUIStyleUtility.ContentEmpty); { GUILayout.Space(5); defaultMaterial = CSG_EditorGUIUtility.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; }