/* * 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 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; }