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, IPositionDriverAdd 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.
Members
verticalfield
public Vertical verticalhorizontalfield
public Horizontal horizontaldepthfield
public Depth depthtargetfield
public Transform targetcaptureThresholdfield
public float captureThresholdWorld-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
| Value | Description |
|---|---|
None | |
Up | |
Down |
Horizontalenum
| Value | Description |
|---|---|
None | |
Left | |
Right |
Depthenum
| Value | Description |
|---|---|
None | |
Forward | |
Back |