Skip to content

Grid Snapping

The Decorating Toolkit has a grid system so you can place objects exactly where you want. It works for the whole world or for specific surfaces like walls.

How it works

Everything uses the IGrid interface. This lets the toolkit use different snapping rules depending on what you're looking at.

The GridDragMotor wraps around other motors. It takes the position, snaps it to the grid, and then tells the other motor where to go.

Snapping Priority

When you drag something: 1. Surface Grid: It first checks if the thing you're looking at has a SurfaceGrid script. If it does, it uses that. This is great for walls or tilted floors. 2. Global Grid: If there's no SurfaceGrid, it uses the global Grid Settings in your toolkit settings asset.

Global Grid Setup

  1. Create the Asset: Right-click and select Create > DecoRat > Decorating > Grid Settings.
  2. Setup: Set the Grid Size and check which axes you want to snap.
  3. Assign: Put the asset into the Grid Settings slot in your DecoratingToolkitSettings.

Surface Grid Setup

If you have a wall that isnt aligned with the world, use a SurfaceGrid:

  1. Add Script: Put the Surface Grid script on the object with the collider.
  2. Setup: Change the Grid Size and offset in the Inspector.
  3. See it: You should see a green grid in the Scene view so you know where it snaps.

API Scripts

  • IGrid: The main interface for snapping.
  • GridSettings: The asset for global snapping.
  • SurfaceGrid: The script for snapping on specific objects.
  • GridDragMotor: The motor that does the actual snapping.