private void DrawFollowToggles() { EditorGUI.BeginChangeCheck(); string followPosDesc = KeybindingManager.instance.GetKeybindingDescription(FOLLOW_POSITION_KEYBINDING_ID); m_isFollowingPosition = EditorGUIExtensions.IconToggle( EditorTextures.GetTexturePath(EditorTextures.GRID_TO_SELECTION_POSITION_UNLOCKED_ICON), EditorTextures.GetTexturePath(EditorTextures.GRID_TO_SELECTION_POSITION_LOCKED_ICON), m_isFollowingPosition, "Stop grid from moving when the selected object is moved " + followPosDesc, "Set grid to move when the selected object is moved " + followPosDesc); if (EditorGUI.EndChangeCheck() && m_isFollowingPosition) { ResetFollowOffset(); } string followRotDesc = KeybindingManager.instance.GetKeybindingDescription(FOLLOW_ROTATION_KEYBINDING_ID); m_isFollowingRotation = EditorGUIExtensions.IconToggle( EditorTextures.GetTexturePath(EditorTextures.GRID_TO_SELECTION_ROTATION_UNLOCKED_ICON), EditorTextures.GetTexturePath(EditorTextures.GRID_TO_SELECTION_ROTATION_LOCKED_ICON), m_isFollowingRotation, "Stop grid from rotating when the selected object is rotated " + followRotDesc, "Set grid to rotate when the selected object is rotated " + followRotDesc); }
private void DrawGlobalOptions() { string visibilityDesc = KeybindingManager.instance.GetKeybindingDescription(VISIBILTY_TOGGLE_KEYBINDING_ID); m_isGridVisible = EditorGUIExtensions.IconToggle(EditorTextures.GetTexturePath(EditorTextures.HIDDEN_ICON), EditorTextures.GetTexturePath(EditorTextures.VISIBLE_ICON), m_isGridVisible, "Hide grid " + visibilityDesc, "Show grid " + visibilityDesc); string posSnapDesc = KeybindingManager.instance.GetKeybindingDescription(POSITION_ENABLED_KEYBINDING_ID); m_isPositionSnapEnabled = EditorGUIExtensions.IconToggle(EditorTextures.GetTexturePath(EditorTextures.POSITION_SNAP_DISABLED_ICON), EditorTextures.GetTexturePath(EditorTextures.POSITION_SNAP_ENABLED_ICON), m_isPositionSnapEnabled, "Disable position snapping " + posSnapDesc, "Enable position snapping " + posSnapDesc); string rotSnapDesc = KeybindingManager.instance.GetKeybindingDescription(ROTATION_ENABLED_KEYBINDING_ID); m_isRotationSnapEnabled = EditorGUIExtensions.IconToggle(EditorTextures.GetTexturePath(EditorTextures.ROTATION_SNAP_DISABLED_ICON), EditorTextures.GetTexturePath(EditorTextures.ROTATION_SNAP_ENABLED_ICON), m_isRotationSnapEnabled, "Disable rotation snapping " + rotSnapDesc, "Enable rotation snapping " + rotSnapDesc); EditorGUILayout.BeginVertical(); { EditorGUI.BeginDisabledGroup(!m_isRotationSnapEnabled); { EditorGUIExtensions.DrawIconPrefixedField(EditorTextures.GetTexturePath(EditorTextures.ROTATION_SNAP_ANGLE_ICON), "The angle in degrees used when rotation snapping is enabled", delegate { m_gridData.rotationSnapAngle = EditorGUILayout.FloatField(m_gridData.rotationSnapAngle, GUILayout.MinWidth(MIN_FIELD_WIDTH)); m_gridData.rotationSnapAngle = Mathf.Clamp(m_gridData.rotationSnapAngle, MIN_ROTATION_SNAP_ANGLE, MAX_ROTATION_SNAP_ANGLE); // degree symbol EditorGUILayout.LabelField(('\u00B0').ToString(), GUILayout.Width(UNIT_LABEL_WIDTH)); }); } EditorGUI.EndDisabledGroup(); EditorGUI.BeginChangeCheck(); { string tooltip = (m_gridData.edgeType == GridData.EdgeType.Infinite ? "Display distance as number of grid cells" : "Grid size (number of cells)"); EditorGUIExtensions.DrawIconPrefixedField(EditorTextures.GetTexturePath(EditorTextures.GRIDSIZE_ICON), tooltip, delegate { m_gridData.gridSize = EditorGUILayout.IntField(m_gridData.gridSize, GUILayout.MinWidth(MIN_FIELD_WIDTH)); m_gridData.gridSize = Mathf.Clamp(m_gridData.gridSize, MIN_GRID_SIZE, MAX_GRID_SIZE); EditorGUILayout.LabelField("u", GUILayout.Width(UNIT_LABEL_WIDTH)); }); } if (EditorGUI.EndChangeCheck()) { GridWindow.ResetSceneGrid(); } } EditorGUILayout.EndVertical(); }
public void DrawProperties() { if ((m_axis == Axis.X && !GridSettings.instance.showXAxisOptions) || (m_axis == Axis.Y && !GridSettings.instance.showYAxisOptions) || (m_axis == Axis.Z && !GridSettings.instance.showZAxisOptions)) { return; } AxisProperties axisProperties = m_gridData.GetAxisProperties(m_axis); EditorGUI.BeginChangeCheck(); Color originalBGColor = GUI.backgroundColor; GUI.backgroundColor = GetAxisColor(m_axis); GUIStyle style = new GUIStyle(GUI.skin.box); style.normal.background = EditorTextures.GetByName(EditorTextures.BORDER_TEX_NAME); style.border = new RectOffset(5, 5, 5, 5); if (GridSettings.instance.gridWindowLayout == LayoutDirection.Vertical) { EditorGUILayout.BeginVertical(style); } else { EditorGUILayout.BeginHorizontal(style); } { GUI.backgroundColor = originalBGColor; m_isFoldoutOpen = EditorGUILayout.Foldout(m_isFoldoutOpen, m_axis + " Axis"); if (m_isFoldoutOpen) { // VISIBLE axisProperties.isVisibleInEditor = EditorGUIExtensions.IconToggle(EditorTextures.GetTexturePath(EditorTextures.HIDDEN_ICON), EditorTextures.GetTexturePath(EditorTextures.VISIBLE_ICON), axisProperties.isVisibleInEditor, "Hide the " + m_axis + " grid plane", "Show the " + m_axis + " grid plane"); // SNAP axisProperties.isSnapEnabled = EditorGUIExtensions.IconToggle(EditorTextures.GetTexturePath(EditorTextures.POSITION_SNAP_DISABLED_ICON), EditorTextures.GetTexturePath(EditorTextures.POSITION_SNAP_ENABLED_ICON), axisProperties.isSnapEnabled, "Disable snapping along the " + m_axis + " axis", "Enable snapping along the " + m_axis + " axis"); string unitAbbrev = UnitUtil.Abbreviation(GridSettings.instance.measurementUnit); EditorGUILayout.BeginVertical(); { // CELL SIZE EditorGUIExtensions.DrawIconPrefixedField(EditorTextures.GetTexturePath(EditorTextures.CELL_SIZE_ICON), "Size of cells along the " + m_axis + " axis", delegate { axisProperties.cellSize = (float)EditorUnitUtil.DrawConvertedSizeField(axisProperties.cellSize, Unit.Meter, GridSettings.instance.measurementUnit, GridWindow.MIN_FIELD_WIDTH); axisProperties.cellSize = Mathf.Max(axisProperties.cellSize, MIN_SIZE); EditorGUILayout.LabelField(unitAbbrev, GUILayout.Width(GridWindow.UNIT_LABEL_WIDTH)); }); // GRID OFFSET EditorGUIExtensions.DrawIconPrefixedField(EditorTextures.GetTexturePath(EditorTextures.GRID_OFFSET_ICON), "Offset of the entire grid along the " + m_axis + " axis", delegate { axisProperties.offset = (float)EditorUnitUtil.DrawConvertedSizeField(axisProperties.offset, Unit.Meter, GridSettings.instance.measurementUnit, GridWindow.MIN_FIELD_WIDTH); EditorGUILayout.LabelField(unitAbbrev, GUILayout.Width(GridWindow.UNIT_LABEL_WIDTH)); }); } EditorGUILayout.EndVertical(); // ROTATION EditorGUIExtensions.DrawIconPrefixedField(EditorTextures.GetTexturePath(EditorTextures.ROTATION_SNAP_ANGLE_ICON), "Rotation of the grid around the " + m_axis + " axis", delegate { axisProperties.rotation = EditorGUILayout.FloatField(axisProperties.rotation, GUILayout.MinWidth(GridWindow.MIN_FIELD_WIDTH)); axisProperties.rotation = Util.Wrap(axisProperties.rotation, MIN_AXIS_ROTATION, MAX_AXIS_ROTATION); // degree symbol EditorGUILayout.LabelField(('\u00B0').ToString(), GUILayout.Width(GridWindow.UNIT_LABEL_WIDTH)); }); } GUI.backgroundColor = GetAxisColor(m_axis); } if (GridSettings.instance.gridWindowLayout == LayoutDirection.Vertical) { EditorGUILayout.EndVertical(); } else { EditorGUILayout.EndHorizontal(); } GUI.backgroundColor = originalBGColor; if (EditorGUI.EndChangeCheck()) { EditorUtility.SetDirty(m_gridData); SavePrefs(); } }