文档

Unity Engine

Unity Engine

Snap

Rounds value to the closest multiple of snap.
阅读时间1 分钟最后更新于 1 个月前

Definition

  • Type: Method
  • Namespace: UnityEngine
  • Assembly: UnityEngine.CoreModule

Snap(float, float)

Rounds value to the closest multiple of snap.
public static float Snap(float val, float snap)

Parameters

The value to round.

snap

The increment to round to.

Returns

Type

Description

floatThe rounded value.

Snap(Vector2, Vector2)

Rounds value to the closest multiple of snap.
public static Vector2 Snap(Vector2 val, Vector2 snap)

Parameters

The value to round.

The increment to round to.

Returns

Type

Description

Vector2The rounded value.

Snap(Vector3, Vector3, SnapAxis)

Rounds value to the closest multiple of snap.
public static Vector3 Snap(Vector3 val, Vector3 snap, SnapAxis axis = SnapAxis.All)

Parameters

The value to round.

The increment to round to.

Restrict snapping to the components on these axes.

Returns

Type

Description

Vector3The rounded value.