class

SurfaceSnap

Editor-time (and play-mode-guarded) world-bounds snap. Drives transform.position on the set world axes so a sibling Renderer's world bounds face lands flush against a resolved surface (raycast hit, collider-less fallback scan, or an explicit target override), independent of the object's own pivot.

public sealed class SurfaceSnap : MonoBehaviour, IPositionDriver

Add it from a builder with NodeHandle.SurfaceSnap or in the inspector. It runs in edit mode only, and re-snaps when the surface underneath moves. Drag the object further than captureThreshold to detach it deliberately. Axes you leave unset are never touched, so an object can snap down to the floor while staying free to move horizontally.

Authoring

Add this component from a NodeHandle inside Build:

SurfaceSnapmethod

public NodeHandle SurfaceSnap(bool up = false, bool down = false, bool left = false, bool right = false, bool forward = false, bool back = false, SceneObjectHandle target = null)

Snap to a surface: at most one horizontal (left/right), one vertical (up/down), and one depth (forward/back) axis, with an optional explicit target override (skips the raycast/fallback scan). The target is any scene object handle — a GameObject or a prefab instance root.

Members

verticalfield

public Vertical vertical

horizontalfield

public Horizontal horizontal

depthfield

public Depth depth

targetfield

public Transform target

captureThresholdfield

public float captureThreshold

World-unit drag distance (measured on snapped axes only) beyond which a manual move is treated as an intentional detach rather than a re-snap. Sticky: once detached the component disables itself (see Evaluate) until re-enabled.

Evaluatemethod

public void Evaluate()

Recompute the position of each set axis so the corresponding bounds face lands flush against the resolved surface for that axis (target override > raycast > collider-less fallback scan). Free (unset) axes are left untouched.

Nested types

Verticalenum

ValueDescription
None
Up
Down

Horizontalenum

ValueDescription
None
Left
Right

Depthenum

ValueDescription
None
Forward
Back

Generated from com.codescenes/Runtime/SurfaceSnap.cs