Legacy Documentation: Version 4.5.0

Script language:

  • JS
  • C#
  • Boo
Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

HandleUtility.ClosestPointToDisc

static function ClosestPointToDisc(center: Vector3, normal: Vector3, radius: float): Vector3;
static Vector3 ClosestPointToDisc(Vector3 center, Vector3 normal, float radius);
static def ClosestPointToDisc(center as Vector3, normal as Vector3, radius as float) as Vector3

Description

Get the point on an disc (in 3D space) which is closest to the current mouse position.

This function takes the disc defined by its parameters and "flattens" it into screen space. The closest point between the flattened disc and the current mouse position (also in screen space) is then found and converted back into a 3D point on the original 3D disc. This is useful for Handle GUIs that involve rotation of an object around the center of the disc; the 2D mouse movements are converted into 3D space in the familiar way used by Unity's built-in tools.