static void GeneratorButton(Rect position, ChiselPlacementToolInstance generator, GUIStyle style, bool isActive) { EditorGUI.BeginChangeCheck(); var content = generator.Content; var isSelected = ChiselGeneratorManager.GeneratorMode == generator; var value = ToggleButton(position, content, isSelected && isActive, style, isActive); if (EditorGUI.EndChangeCheck()) { if (Event.current.button == 2) { ChiselPlacementToolsSelectionWindow.SetInToolBox(generator, false); } else { if (value) { ChiselPlacementTool.ActivateTool(); ChiselGeneratorManager.GeneratorMode = generator; ChiselEditorSettings.Save(); } SceneView.RepaintAll(); } } }
static void NamedGeneratorButton(ChiselPlacementToolInstance generator, Rect togglePosition, GUIStyle style, bool isActive) { var temp = togglePosition; temp.xMin += 5; temp.width = 20; { EditorGUI.BeginChangeCheck(); var value = GUI.Toggle(temp, generator.InToolBox, GUIContent.none); if (EditorGUI.EndChangeCheck()) { SetInToolBox(generator, value); } } temp = togglePosition; temp.xMin += 25; { EditorGUI.BeginChangeCheck(); var content = ChiselEditorResources.GetIconContentWithName(generator.ToolName, generator.ToolName)[0]; var isSelected = ChiselGeneratorManager.GeneratorMode == generator; var value = ToggleButton(temp, content, isSelected, style, isActive); if (EditorGUI.EndChangeCheck() && value) { // TODO: make undoable generator.InToolBox = true; ChiselPlacementTool.ActivateTool(); ChiselGeneratorManager.GeneratorMode = generator; ChiselEditorSettings.Save(); SceneView.RepaintAll(); } } }
public static void HalfScaleSnap() { GUIUtility.keyboardControl = 0; MultiplyScaleSnapDistance(0.5f); ChiselEditorSettings.Save(); SceneView.RepaintAll(); }
static void DisplayControls(SceneView sceneView) { InitStyles(); EditorGUI.BeginChangeCheck(); { var enabled = HaveNodesInSelection(); var values = editModes.Values; if (values.Count > 0) { using (new EditorGUI.DisabledScope(!enabled)) { var style = styles.toggleStyleMid; var groupRect = EditorGUILayout.GetControlRect(false, style.fixedHeight + style.margin.vertical, ChiselOverlay.kMinWidthLayout); groupRect.xMin -= 3; groupRect.yMin += 3; var startX = style.margin.left + groupRect.x + 4; var buttonStep = style.fixedWidth + style.margin.left; var position = new Rect(startX, groupRect.y, style.fixedWidth, style.fixedHeight); int xPos = 0; var count = values.Count; var index = 0; for (int i = 0; i < count; i++) { var editMode = values[i]; var toggleStyle = (index == 0) ? styles.toggleStyleLeft : (index == count - 1) && (count < 7) ? styles.toggleStyleRight : styles.toggleStyleMid; position.x = startX + (xPos * buttonStep); EditModeButton(position, enabled, editMode, toggleStyle); index++; xPos++; } // TODO: assign hotkey to rebuild, and possibly move it elsewhere to avoid it seemingly like a necessary action. xPos = 7; position.x = startX + (xPos * buttonStep); var buttonStyle = (index == 7) ? styles.toggleStyleRight : styles.toggleStyle; if (kRebuildButton == null) { kRebuildButton = ChiselEditorResources.GetIconContent(kRebuildIconName, kRebuildTooltip)[0]; } if (GUI.Toggle(position, false, kRebuildButton, buttonStyle)) { Rebuild(); } } } ChiselPlacementToolsSelectionWindow.RenderCreationTools(); } if (EditorGUI.EndChangeCheck()) { ChiselEditorSettings.Save(); } }
public static void DoubleRotateSnap() { GUIUtility.keyboardControl = 0; MultiplyRotateSnapDistance(2.0f); ChiselEditorSettings.Save(); SceneView.RepaintAll(); }
static void OnBottomBarUIFunction(int windowID) { EditorGUI.BeginChangeCheck(); GUILayout.BeginHorizontal(); // TODO: assign hotkey to rebuild, and possibly move it elsewhere to avoid it seemingly like a necessary action. if (GUILayout.Button(rebuildButton, ChiselSceneGUIStyle.buttonStyle)) { Rebuild(); } GUILayout.FlexibleSpace(); ChiselEditorSettings.ShowGrid = GUILayout.Toggle(ChiselEditorSettings.ShowGrid, "Show Grid", ChiselSceneGUIStyle.toggleStyle); ChiselEditorSettings.UniformSnapDistance = EditorGUILayout.FloatField(ChiselEditorSettings.UniformSnapDistance, floatWidthLayout); if (GUILayout.Button(halveSnapDistanceButton, EditorStyles.miniButtonLeft, sizeButtonWidth)) { SnappingKeyboard.HalfGridSize(); } if (GUILayout.Button(doubleSnapDistanceButton, EditorStyles.miniButtonRight, sizeButtonWidth)) { SnappingKeyboard.DoubleGridSize(); } GUILayout.EndHorizontal(); if (EditorGUI.EndChangeCheck()) { ChiselEditorSettings.Save(); } }
static void DisplayControls(SceneView sceneView) { if (styles == null) { styles = new Styles(); } EditorGUI.BeginChangeCheck(); { // TODO: implement all snapping types // TODO: add units (EditorGUI.s_UnitString?) //ChiselEditorSettings.ShowGrid = GUILayout.Toggle(ChiselEditorSettings.ShowGrid, "Show Grid", EditorStyles.miniButton, kShowGridButtonWidthOption); var usedSnappingModes = CurrentSnapSettings(); GUILayout.BeginHorizontal(); { GUILayout.Space(1); Snapping.BoundsSnappingEnabled = ToggleButton(Snapping.BoundsSnappingEnabled, usedSnappingModes, SnapSettings.GeometryBoundsToGrid, styles.boundsSnapIcons, styles.toggleStyleLeft); Snapping.PivotSnappingEnabled = ToggleButton(Snapping.PivotSnappingEnabled, usedSnappingModes, SnapSettings.GeometryPivotToGrid, styles.pivotSnapIcons, styles.toggleStyleMid); Snapping.EdgeSnappingEnabled = ToggleButton(Snapping.EdgeSnappingEnabled, usedSnappingModes, SnapSettings.GeometryEdge, styles.edgeSnapIcons, styles.toggleStyleMid); Snapping.VertexSnappingEnabled = ToggleButton(Snapping.VertexSnappingEnabled, usedSnappingModes, SnapSettings.GeometryVertex, styles.vertexSnapIcons, styles.toggleStyleMid); Snapping.SurfaceSnappingEnabled = ToggleButton(Snapping.SurfaceSnappingEnabled, usedSnappingModes, SnapSettings.GeometrySurface, styles.surfaceSnapIcons, styles.toggleStyleMid); Snapping.UVGridSnappingEnabled = ToggleButton(Snapping.UVGridSnappingEnabled, usedSnappingModes, SnapSettings.UVGeometryGrid, styles.uvGridSnapIcons, styles.toggleStyleMid); Snapping.UVEdgeSnappingEnabled = ToggleButton(Snapping.UVEdgeSnappingEnabled, usedSnappingModes, SnapSettings.UVGeometryEdges, styles.uvEdgeSnapIcons, styles.toggleStyleMid); Snapping.UVVertexSnappingEnabled = ToggleButton(Snapping.UVVertexSnappingEnabled, usedSnappingModes, SnapSettings.UVGeometryVertices, styles.uvVertexSnapIcons, styles.toggleStyleRight); GUILayout.Space(1); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Space(1); { Snapping.TranslateSnappingEnabled = SmallToggleButton(Snapping.TranslateSnappingEnabled, styles.translateIcons); ChiselEditorSettings.UniformSnapSize = PlusMinusFloatField(ChiselEditorSettings.UniformSnapSize, kDoubleGridSize, kHalfGridSize, SnappingKeyboard.DoubleGridSizeRet, SnappingKeyboard.HalfGridSizeRet); } GUILayout.Space(1); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Space(1); { Snapping.RotateSnappingEnabled = SmallToggleButton(Snapping.RotateSnappingEnabled, styles.rotateIcons); ChiselEditorSettings.RotateSnap = PlusMinusFloatField(ChiselEditorSettings.RotateSnap, kDoubleRotateSnap, kHalfRotateSnap, SnappingKeyboard.DoubleRotateSnapRet, SnappingKeyboard.HalfRotateSnapRet); } { Snapping.ScaleSnappingEnabled = SmallToggleButton(Snapping.ScaleSnappingEnabled, styles.scaleIcons); ChiselEditorSettings.ScaleSnap = PlusMinusFloatField(ChiselEditorSettings.ScaleSnap, kDoubleScaleSnap, kHalfScaleSnap, SnappingKeyboard.DoubleScaleSnapRet, SnappingKeyboard.HalfScaleSnapRet); } GUILayout.Space(1); } GUILayout.EndHorizontal(); } if (EditorGUI.EndChangeCheck()) { ChiselEditorSettings.Save(); } }
public override void OnGUI() { EditorGUI.BeginChangeCheck(); { ChiselPlacementToolsSelectionWindow.RenderCreationTools(); } if (EditorGUI.EndChangeCheck()) { ChiselEditorSettings.Save(); } }
static void DisplayControls(SceneView sceneView) { EditorGUI.BeginChangeCheck(); { AdditionalSettings?.Invoke(sceneView); } if (EditorGUI.EndChangeCheck()) { ChiselEditorSettings.Save(); } }
static void EditModeButton(Rect position, bool enabled, ChiselEditToolBase editMode, GUIStyle style) { var editModeType = editMode.GetType(); using (new EditorGUI.DisabledScope(!enabled)) { EditorGUI.BeginChangeCheck(); var value = Toggle(position, editMode, editModeType, style); if (EditorGUI.EndChangeCheck() && value) { ToolManager.SetActiveTool(editModeType); ChiselEditorSettings.Save(); } } }
private static void GridOnSceneGUI(SceneView sceneView) { if (Event.current.type != EventType.Repaint) { return; } if (ShowUnityGrid) { ShowUnityGrid = false; ChiselEditorSettings.Load(); ChiselEditorSettings.ShowGrid = false; ChiselEditorSettings.Save(); } if (Tools.pivotRotation == PivotRotation.Local) { var activeTransform = Selection.activeTransform; var rotation = Tools.handleRotation; var center = (activeTransform && activeTransform.parent) ? activeTransform.parent.position : Vector3.zero; UnitySceneExtensions.Grid.defaultGrid.GridToWorldSpace = Matrix4x4.TRS(center, rotation, Vector3.one); } else { UnitySceneExtensions.Grid.defaultGrid.GridToWorldSpace = Matrix4x4.identity; } if (ChiselEditorSettings.ShowGrid) { var grid = UnitySceneExtensions.Grid.HoverGrid; if (grid != null) { grid.Spacing = UnitySceneExtensions.Grid.defaultGrid.Spacing; } else { grid = UnitySceneExtensions.Grid.ActiveGrid; } grid.Render(sceneView); } if (UnitySceneExtensions.Grid.debugGrid != null) { UnitySceneExtensions.Grid.debugGrid.Render(sceneView); } }
static void EditModeButton(ChiselEditModeManager.ChiselEditModeItem editMode, Rect togglePosition) { EditorGUI.BeginChangeCheck(); var value = GUI.Toggle(togglePosition, ChiselEditModeManager.EditMode == editMode.instance, editMode.content, GUI.skin.button); if (EditorGUI.EndChangeCheck() && value) { // If we're changing edit mode from a generator, we restore our previous selection. if (Instance.HaveStoredEditModeState()) { RestoreEditModeState(skipEditMode: true); } ChiselEditModeManager.EditMode = editMode.instance; ChiselEditorSettings.Save(); } }
static void OnWindowGUI(Rect position) { var editModes = ChiselEditModeManager.editModes; var generatorModes = ChiselEditModeManager.generatorModes; var togglePosition = position; togglePosition.height = kSingleLineHeight * 2; togglePosition.width *= 0.5f; EditModeButton(editModes[0], togglePosition); togglePosition.x += togglePosition.width; EditModeButton(editModes[1], togglePosition); togglePosition.y += kSingleLineHeight * 2; EditModeButton(editModes[3], togglePosition); togglePosition.x -= togglePosition.width; EditModeButton(editModes[2], togglePosition); // Spacing togglePosition.y += kSingleLineHeight * 2; togglePosition.y += kGeneratorSeparator; // Reset button size // togglePosition.x -= togglePosition.width; togglePosition.width *= 2f; togglePosition.height = kSingleLineHeight; for (int i = 0; i < generatorModes.Length; i++) { var editMode = generatorModes[i]; EditorGUI.BeginChangeCheck(); var value = GUI.Toggle(togglePosition, ChiselEditModeManager.EditMode == editMode.instance, editMode.content, GUI.skin.button); if (EditorGUI.EndChangeCheck() && value) { // When we select a generator, we don't want anything else selected since the combination makes no sense. // We store the selection, however, if our previous edit mode was not a generator. if (!(ChiselEditModeManager.EditMode is ChiselGeneratorToolMode)) { Instance.StoreEditModeState(); } ChiselEditModeManager.EditMode = editMode.instance; ChiselEditorSettings.Save(); } togglePosition.y += kSingleLineHeight + kSingleSpacing; } }
static void GeneratorButton(ChiselEditModeManager.ChiselEditModeItem generator, Rect togglePosition) { EditorGUI.BeginChangeCheck(); var value = Toggle(togglePosition, generator); if (EditorGUI.EndChangeCheck() && value) { // When we select a generator, we don't want anything else selected since the combination makes no sense. // We store the selection, however, if our previous edit mode was not a generator. if (!(ChiselEditModeManager.EditMode is ChiselGeneratorToolMode)) { Instance.StoreEditModeState(); } ChiselEditModeManager.EditMode = generator.instance; ChiselEditorSettings.Save(); } }
// TODO: move somewhere else public static void SetInToolBox(ChiselPlacementToolInstance generator, bool value) { // TODO: make undoable generator.InToolBox = value; if (ChiselGeneratorManager.GeneratorMode == generator) { if (!DeselectGeneratorMode()) { generator.InToolBox = true; } } ChiselEditorSettings.Save(); if (Event.current.type != EventType.Repaint) { SceneView.RepaintAll(); } }
internal static void GridOnSceneGUI(SceneView sceneView) { if (sceneView.showGrid) { sceneView.showGrid = false; ChiselEditorSettings.Load(); ChiselEditorSettings.ShowGrid = true; ChiselEditorSettings.Save(); } var sceneViewGrids = sceneViewGridsProperty?.GetValue(sceneView); GridRenderer.Opacity = gridOpacityProperty?.GetValue(sceneViewGrids) ?? 1.0f; var activeTransform = Selection.activeTransform; if (Tools.pivotRotation == PivotRotation.Local && activeTransform) { var rotation = Tools.handleRotation; var center = (activeTransform && activeTransform.parent) ? activeTransform.parent.position : Vector3.zero; UnitySceneExtensions.Grid.defaultGrid.GridToWorldSpace = Matrix4x4.TRS(center, rotation, Vector3.one); } else { var gridAxis = gridAxisProperty?.GetValue(sceneViewGrids) ?? 1; switch (gridAxis) { case 0: UnitySceneExtensions.Grid.defaultGrid.GridToWorldSpace = UnitySceneExtensions.Grid.XYPlane; break; case 1: UnitySceneExtensions.Grid.defaultGrid.GridToWorldSpace = UnitySceneExtensions.Grid.XZPlane; break; case 2: UnitySceneExtensions.Grid.defaultGrid.GridToWorldSpace = UnitySceneExtensions.Grid.YZPlane; break; } } if (Event.current.type != EventType.Repaint) { return; } if (ChiselEditorSettings.ShowGrid) { var grid = UnitySceneExtensions.Grid.HoverGrid; if (grid != null) { grid.Spacing = UnitySceneExtensions.Grid.defaultGrid.Spacing; } else { grid = UnitySceneExtensions.Grid.ActiveGrid; } grid.Render(sceneView); } if (UnitySceneExtensions.Grid.debugGrid != null) { //static ReflectedInstanceProperty<object> sceneViewGrids = typeof(SceneView).GetProperty<object>("sceneViewGrids"); //static ReflectedInstanceProperty<float> gridOpacity = ReflectionExtensions.GetProperty<float>("SceneViewGrid", "gridOpacity"); UnitySceneExtensions.Grid.debugGrid.Render(sceneView); } }
public static void MultiplyRotateSnapDistance(float modifier) { ChiselEditorSettings.RotateSnap = ChiselEditorSettings.RotateSnap * modifier; ChiselEditorSettings.Save(); }
public static void DoubleGridSize() { MultiplySnapDistance(2.0f); ChiselEditorSettings.Save(); SceneView.RepaintAll(); }
public static void ToggleBoundsSnapping() { ChiselEditorSettings.BoundsSnapping = !ChiselEditorSettings.BoundsSnapping; ChiselEditorSettings.Save(); SceneView.RepaintAll(); }
public static void ToggleGridVisibility() { ChiselEditorSettings.ShowGrid = !ChiselEditorSettings.ShowGrid; ChiselEditorSettings.Save(); SceneView.RepaintAll(); }
public static void MultiplyGridSnapDistance(float modifier) { ChiselEditorSettings.UniformSnapSize = ChiselEditorSettings.UniformSnapSize * modifier; ChiselEditorSettings.Save(); }
static void DisplayControls(SceneView sceneView) { if (styles == null) { styles = new Styles(); } EditorGUI.BeginChangeCheck(); { // TODO: implement all snapping types // TODO: add units (EditorGUI.s_UnitString?) //ChiselEditorSettings.ShowGrid = GUILayout.Toggle(ChiselEditorSettings.ShowGrid, "Show Grid", EditorStyles.miniButton, kShowGridButtonWidthOption); var usedSnappingModes = CurrentSnapSettings(); { var buttonRect = EditorGUILayout.GetControlRect(false, styles.toggleStyleLeft.fixedHeight, styles.toggleStyleLeft, kToggleWidth); buttonRect.x++; Snapping.BoundsSnappingEnabled = ToggleButton(buttonRect, Snapping.BoundsSnappingEnabled, usedSnappingModes, SnapSettings.GeometryBoundsToGrid, styles.boundsSnapIcons, styles.toggleStyleLeft); buttonRect.x += buttonRect.width; Snapping.PivotSnappingEnabled = ToggleButton(buttonRect, Snapping.PivotSnappingEnabled, usedSnappingModes, SnapSettings.GeometryPivotToGrid, styles.pivotSnapIcons, styles.toggleStyleMid); buttonRect.x += buttonRect.width; Snapping.EdgeSnappingEnabled = ToggleButton(buttonRect, Snapping.EdgeSnappingEnabled, usedSnappingModes, SnapSettings.GeometryEdge, styles.edgeSnapIcons, styles.toggleStyleMid); buttonRect.x += buttonRect.width; Snapping.VertexSnappingEnabled = ToggleButton(buttonRect, Snapping.VertexSnappingEnabled, usedSnappingModes, SnapSettings.GeometryVertex, styles.vertexSnapIcons, styles.toggleStyleMid); buttonRect.x += buttonRect.width; Snapping.SurfaceSnappingEnabled = ToggleButton(buttonRect, Snapping.SurfaceSnappingEnabled, usedSnappingModes, SnapSettings.GeometrySurface, styles.surfaceSnapIcons, styles.toggleStyleMid); buttonRect.x += buttonRect.width; Snapping.UVGridSnappingEnabled = ToggleButton(buttonRect, Snapping.UVGridSnappingEnabled, usedSnappingModes, SnapSettings.UVGeometryGrid, styles.uvGridSnapIcons, styles.toggleStyleMid); buttonRect.x += buttonRect.width; Snapping.UVEdgeSnappingEnabled = ToggleButton(buttonRect, Snapping.UVEdgeSnappingEnabled, usedSnappingModes, SnapSettings.UVGeometryEdges, styles.uvEdgeSnapIcons, styles.toggleStyleMid); buttonRect.x += buttonRect.width; Snapping.UVVertexSnappingEnabled = ToggleButton(buttonRect, Snapping.UVVertexSnappingEnabled, usedSnappingModes, SnapSettings.UVGeometryVertices, styles.uvVertexSnapIcons, styles.toggleStyleRight); } EditorGUILayout.GetControlRect(false, 1); { var lineRect = EditorGUILayout.GetControlRect(false, styles.smallToggleStyle.fixedHeight); lineRect.xMin++; lineRect.xMax--; { var buttonRect = lineRect; buttonRect.width = kSmallButtonWidth + styles.smallToggleStyle.margin.horizontal; Snapping.TranslateSnappingEnabled = SmallToggleButton(buttonRect, Snapping.TranslateSnappingEnabled, styles.translateIcons); var floatRect = lineRect; floatRect.x = buttonRect.xMax + 1; floatRect.width -= buttonRect.width + 1; ChiselEditorSettings.UniformSnapSize = PlusMinusFloatField(floatRect, ChiselEditorSettings.UniformSnapSize, kDoubleGridSize, kHalfGridSize, SnappingKeyboard.DoubleGridSizeRet, SnappingKeyboard.HalfGridSizeRet); } } { var lineRect = EditorGUILayout.GetControlRect(false, styles.smallToggleStyle.fixedHeight); lineRect.xMin++; lineRect.xMax--; var buttonRect1 = lineRect; var buttonRect2 = lineRect; var floatRect1 = lineRect; var floatRect2 = lineRect; buttonRect1.width = kSmallButtonWidth + styles.smallToggleStyle.margin.horizontal; buttonRect2.width = kSmallButtonWidth + styles.smallToggleStyle.margin.horizontal; var floatLeftover = lineRect.width - (buttonRect1.width + buttonRect2.width) - 2; var halfFloatLeftover = Mathf.CeilToInt(floatLeftover / 2); floatRect1.width = halfFloatLeftover - 1; floatRect2.width = (floatLeftover - floatRect1.width) - 2; floatRect1.x = buttonRect1.xMax + 1; buttonRect2.x = floatRect1.xMax + 3; floatRect2.x = buttonRect2.xMax; { Snapping.RotateSnappingEnabled = SmallToggleButton(buttonRect1, Snapping.RotateSnappingEnabled, styles.rotateIcons); ChiselEditorSettings.RotateSnap = PlusMinusFloatField(floatRect1, ChiselEditorSettings.RotateSnap, kDoubleRotateSnap, kHalfRotateSnap, SnappingKeyboard.DoubleRotateSnapRet, SnappingKeyboard.HalfRotateSnapRet); } { Snapping.ScaleSnappingEnabled = SmallToggleButton(buttonRect2, Snapping.ScaleSnappingEnabled, styles.scaleIcons); ChiselEditorSettings.ScaleSnap = PlusMinusFloatField(floatRect2, ChiselEditorSettings.ScaleSnap, kDoubleScaleSnap, kHalfScaleSnap, SnappingKeyboard.DoubleScaleSnapRet, SnappingKeyboard.HalfScaleSnapRet); } } } if (EditorGUI.EndChangeCheck()) { ChiselEditorSettings.Save(); } }
public override void OnGUI() { var groupRect = EditorGUILayout.GetControlRect(false, 0, kMinWidthLayout); if (styles == null) { styles = new Styles(); } EditorGUI.BeginChangeCheck(); { // TODO: implement all snapping types // TODO: add units (EditorGUI.s_UnitString?) //ChiselEditorSettings.ShowGrid = GUILayout.Toggle(ChiselEditorSettings.ShowGrid, "Show Grid", EditorStyles.miniButton, kShowGridButtonWidthOption); var usedSnappingModes = ChiselSnappingToggleUtility.CurrentSnapSettings(); EditorGUILayout.GetControlRect(false, 1); { var lineRect = EditorGUILayout.GetControlRect(false, styles.smallToggleStyle.fixedHeight); lineRect.xMin++; lineRect.xMax--; { var buttonRect = lineRect; buttonRect.width = kSmallButtonWidth + styles.smallToggleStyle.margin.horizontal; Snapping.TranslateSnappingEnabled = SmallToggleButton(buttonRect, Snapping.TranslateSnappingEnabled, styles.translateIcons); var floatRect = lineRect; floatRect.x = buttonRect.xMax + 1; floatRect.width -= buttonRect.width + 1; ChiselEditorSettings.UniformSnapSize = PlusMinusFloatField(floatRect, ChiselEditorSettings.UniformSnapSize, kDoubleGridSize, kHalfGridSize, SnappingKeyboard.DoubleGridSizeRet, SnappingKeyboard.HalfGridSizeRet); } } { var lineRect = EditorGUILayout.GetControlRect(false, styles.smallToggleStyle.fixedHeight); lineRect.xMin++; lineRect.xMax--; var buttonRect1 = lineRect; var buttonRect2 = lineRect; var floatRect1 = lineRect; var floatRect2 = lineRect; buttonRect1.width = kSmallButtonWidth + styles.smallToggleStyle.margin.horizontal; buttonRect2.width = kSmallButtonWidth + styles.smallToggleStyle.margin.horizontal; var floatLeftover = lineRect.width - (buttonRect1.width + buttonRect2.width) - 2; var halfFloatLeftover = Mathf.CeilToInt(floatLeftover / 2); floatRect1.width = halfFloatLeftover - 1; floatRect2.width = (floatLeftover - floatRect1.width) - 2; floatRect1.x = buttonRect1.xMax + 1; buttonRect2.x = floatRect1.xMax + 3; floatRect2.x = buttonRect2.xMax; { Snapping.RotateSnappingEnabled = SmallToggleButton(buttonRect1, Snapping.RotateSnappingEnabled, styles.rotateIcons); ChiselEditorSettings.RotateSnap = PlusMinusFloatField(floatRect1, ChiselEditorSettings.RotateSnap, kDoubleRotateSnap, kHalfRotateSnap, SnappingKeyboard.DoubleRotateSnapRet, SnappingKeyboard.HalfRotateSnapRet); } { Snapping.ScaleSnappingEnabled = SmallToggleButton(buttonRect2, Snapping.ScaleSnappingEnabled, styles.scaleIcons); ChiselEditorSettings.ScaleSnap = PlusMinusFloatField(floatRect2, ChiselEditorSettings.ScaleSnap, kDoubleScaleSnap, kHalfScaleSnap, SnappingKeyboard.DoubleScaleSnapRet, SnappingKeyboard.HalfScaleSnapRet); } } } if (EditorGUI.EndChangeCheck()) { ChiselEditorSettings.Save(); } }