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 轴将游戏对象与网格对齐:
还能以增量方式变换游戏对象,而无需将其与网格线对齐。如果需要更改移动、旋转或缩放的量,则可以更改递增的对齐值。
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 对其进行自定义。
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.
本节提供有关如何执行以下操作的信息:
可以将游戏对象对齐到单个轴上的最近网格点,也可以一次性在所有轴上对齐游戏对象。
要将游戏对象与特定轴的网格上的最近点对齐,请执行以下操作:
In the Grid and Snap Overlays toolbar, open the grid snapping drop-down menu ().
In the Align Selected section, click the X, Y, or Z button that matches the axis you want to push to.
要一次性在所有轴上对齐游戏对象,请执行以下操作:
选择要与网格对齐的游戏对象。
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.
要开启自动贴靠网格,请执行以下操作:
启用自动网格贴靠时,__Move、Rotate__ 和 Scale 变换工具会沿激活的辅助图标轴将选定的游戏对象贴靠到网格。如果需要游戏对象以较小的增量移动,也可以采用增量方式变换游戏对象。
要按增量贴靠值来移动、旋转或缩放,请执行以下操作:
要更改默认的增量贴靠值,请执行以下操作:
From the Grid and Snap Overlays toolbar, open the snap increment drop-down menu ().
Increment Snap 部分包含几个属性,可用于为所有轴设置相同的值或不同的值:
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.
本节提供有关自定义以下设置的信息:
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.
要更改显示网格的轴,请执行以下操作:
From the Grid and Snap Overlays toolbar, open the grid visibility drop-down menu ().
From the Grid Plane section, select the axis you want to appear.
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.
要调整网格的大小,请执行以下操作:
Tip: Use these keyboard shortcuts to increase or decrease the size of the grid:
To change the color of the visible grid lines in the Scene view window:
Open the Preferences window.
从列表中单击 Colors 类别以查看 Colors 页面。
使用 Grid 属性的拾色器选择一种新颜色。
如果网格线太浅或太深,可以进行调整:
From the Grid and Snap Overlays toolbar, open the grid visibility drop-down menu ().
Adjust the Opacity using the slider.
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).
要将网格轴和不透明度设置重置为其默认值,请执行以下操作:
From the Grid and Snap Overlays toolbar, open the grid visibility drop-down menu ().
Click the More menu (⋮) and then click Reset.
要将网格的大小重置为默认值,请执行以下操作:
From the Grid and Snap Overlays toolbar, open the grid snapping drop-down menu ().
Click the More menu (⋮) and then click Reset.
要将增量贴靠值重置为默认值,请执行以下操作:
From the Grid and Snap Overlays toolbar, open the snap increment drop-down menu ().
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。