Version: 2023.2
Position GameObjects
Scene 视图导航

网格对齐

Unity provides a visual grid in the Editor’s Scene view window, which can help precisely align GameObjects by snapping (moving) them to the nearest grid location.

显示沿 x、y 和 z 轴的网格线的同一视图
显示沿 x、y 和 z 轴的网格线的同一视图

可以通过几种方式沿 X、Y 或 Z 轴将游戏对象与网格对齐:

还能以增量方式变换游戏对象,而无需将其与网格线对齐。如果需要更改移动、旋转或缩放的量,则可以更改递增的对齐值。

By default, the grid is hidden, but you can make it visible and change which axis it appears along. You can customize the grid in appearance and behavior by changing the following:

其中很多操作都支持键盘快捷键。可以查看为这些操作分配了哪些组合键,并使用 Shortcuts Manager 对其进行自定义。

Grid and Snap toolbar Overlay

Grid and Snap toolbar Overlay
Grid and Snap toolbar Overlay
Icon Actions
Grid visibility Toggle grid on or off
Change grid axis
Change grid opacity
Move grid to gizmo handle or back to origin
Grid snapping Toggle grid snapping on or off
Change grid size
Align a GameObject to an axis
Snap increment Change the default increment snap values

Note: The settings on the Grid and Snap Overlay are global to all Scene views.

Align, snap, and incremental movements

本节提供有关如何执行以下操作的信息:

Align (push) to the grid

可以将游戏对象对齐到单个轴上的最近网格点,也可以一次性在所有轴上对齐游戏对象。

要将游戏对象与特定轴的网格上的最近点对齐,请执行以下操作:

  1. In the Grid and Snap Overlays toolbar, open the grid snapping drop-down menu ().

  2. In the Align Selected section, click the X, Y, or Z button that matches the axis you want to push to.

    Align Selection to Grid section of the Grid and Snap window
    Align Selection to Grid section of the Grid and Snap window

要一次性在所有轴上对齐游戏对象,请执行以下操作:

  1. 选择要与网格对齐的游戏对象。

  2. Use the Ctrl+\ (Windows) or Cmd+\ (macOS) shortcut to push the GameObject(s) onto the grids on all axes.

    Alternatively, from the Grid and Snap Overlays toolbar, open the grid visibility drop-down menu () and in the Align Selected section, click All Axes.

Activate auto-snapping

要开启自动贴靠网格,请执行以下操作:

  1. Activate the Move tool and make sure the handle orientation in the Tool Settings Overlay is set to Global ().
  2. Click the grid snapping icon () in the Grid and Snap toolbar Overlay. The icon is blue when activated.

启用自动网格贴靠时,__MoveRotate__ 和 Scale 变换工具会沿激活的辅助图标轴将选定的游戏对象贴靠到网格。如果需要游戏对象以较小的增量移动,也可以采用增量方式变换游戏对象

Move, rotate, and scale in increments

要按增量贴靠值来移动、旋转或缩放,请执行以下操作:

  • 按住 Control 键 (Windows) 或 Command 键 (macOS),同时使用其中一个变换辅助图标

要更改默认的增量贴靠值,请执行以下操作:

  1. From the Grid and Snap Overlays toolbar, open the snap increment drop-down menu ().

  2. Increment Snap 部分包含几个属性,可用于为所有轴设置相同的值或不同的值:

    Increment Snap section of the Grid and Snap window
    Increment Snap section of the Grid and Snap window

    Move: With the link icon selected, enter a uniform increment snap value for all axes, or unlink the axes and set different increment snap values in the X, Y, and Z axis properties.

    Rotate: Enter a rotation increment value in degrees.

    Scale: Enter a scale increment value as a scale factor. For example, if the Scale value is 2, the selected GameObject will scale at an increment of twice its original size.

Customize the grid

本节提供有关自定义以下设置的信息:

Show and hide grid lines

Toggle grid visibility by clicking the grid visibility icon () on the Grid and Snap Overlay toolbar to display or hide the grid on any axis (X, Y, Z). If you are in orthographic mode (Iso), Unity chooses the view.

The grid appears in the Scene view window when you click the grid visibility button
The grid appears in the Scene view window when you click the grid visibility button

Change the axis where the grid appears

要更改显示网格的轴,请执行以下操作:

  1. From the Grid and Snap Overlays toolbar, open the grid visibility drop-down menu ().

  2. From the Grid Plane section, select the axis you want to appear.

    The Grid Axis section under the grid visibility drop-down menu
    The Grid Axis section under the grid visibility drop-down menu

Resize the grid

You can set the size of the grid lines that display in the Scene view window. The size of the grid affects how your grid looks and how your GameObjects automatically snap to the grid, but doesn’t affect how your GameObjects move, rotate, or scale in increments.

If you set a size for all axes at once, a uniform, square-based, grid displays. However, you can also use different values on any of the three axes to display a non-uniform, rectangular-based, grid. By default, the grid is set to a uniform distance of 1 on all axes.

要调整网格的大小,请执行以下操作:

  1. In the Grid and Snap overlay, select the arrow next to the Grid Snapping button to open the Snapping menu.
  2. To enter a uniform value for the grid size and make all grid lines the same length:
    1. Select the link icon in the Size property.
    2. Enter a value for the X property to set the size of the grid lines on all axes.
  3. To enter non-uniform values for the grid size and specify the size of the grid lines on for each axis separately:
    1. Make sure that the link icon in the Size property is not selected.
    2. Enter a value for the X, Y, and Z properties to set the size of the grid lines on each axis.

Tip: Use these keyboard shortcuts to increase or decrease the size of the grid:

  • To increase the grid size, press Ctrl+] (MacOS: Cmd+]).
  • To decrease the grid size, press Ctrl+[ (MacOS: Cmd+[).

Change the default color of the grid lines

To change the color of the visible grid lines in the Scene view window:

  1. Open the Preferences window.

  2. 从列表中单击 Colors 类别以查看 Colors 页面。

    Preferences 页面上的网格偏好设置属性
    Preferences 页面上的网格偏好设置属性
  3. 使用 Grid 属性的拾色器选择一种新颜色。

Change the opacity of the grid

如果网格线太浅或太深,可以进行调整:

  1. From the Grid and Snap Overlays toolbar, open the grid visibility drop-down menu ().

  2. Adjust the Opacity using the slider.

    Adjust opacity in the grid visibility drop-down menu
    Adjust opacity in the grid visibility drop-down menu

Move the grid to the handle of a GameObject

From the grid visibility drop-down menu () in the Grid and Snap Overlay toolbar, use the Move To section to move the grid to the handle of the selected GameObject (Handle) or back to the default position (Origin).

Reset values and settings to default

要将网格轴和不透明度设置重置为其默认值,请执行以下操作:

  1. From the Grid and Snap Overlays toolbar, open the grid visibility drop-down menu ().

  2. Click the More menu (⋮) and then click Reset.

要将网格的大小重置为默认值,请执行以下操作:

  1. From the Grid and Snap Overlays toolbar, open the grid snapping drop-down menu ().

  2. Click the More menu (⋮) and then click Reset.

要将增量贴靠值重置为默认值,请执行以下操作:

  1. From the Grid and Snap Overlays toolbar, open the snap increment drop-down menu ().

  2. Click the More menu (⋮) and then click Reset.

    只有 Increment Snap 部分下的值会恢复为其原始默认值。

默认快捷键

可以使用默认 Unity 快捷键执行以下操作:

操作 默认快捷键
增大网格大小 Ctrl+] (Windows) 或
Command+] (macOS)
减小网格大小 Ctrl+[ (Windows) 或
Command+[ (macOS)
推动到网格(将所选对象与网格对齐) Ctrl+\ (Windows) 或
Command+\ (macOS)
重置网格 (默认情况下没有快捷键)

要更改这些默认快捷键,请使用 Shortcuts Manager


  • 2019.3 中更新了本地网格改进 NewIn20193
  • Grid and snap moved to Overlays toolbar updated in 2021.2 NewIn20212
Position GameObjects
Scene 视图导航