Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


WorldToGUIPoint(Vector3)

Convert a world space point to a 2D GUI position.
Read time 1 minuteLast updated 4 days ago

Definition

  • Type: Method
  • Namespace: UnityEditor
  • Assembly: UnityEditor
public static Vector2 WorldToGUIPoint(Vector3 world)

Parameters

world

Point in world space.

Returns

Type

Description

Vector2A Vector2 where the x and y values are the 2D GUI position of the world space point.

Remarks

Uses the current camera to calculate the projection. Use this to place Editor GUI elements based on world positions.
If the world point is outside the camera's frustum,
WorldToGUIPoint
returns x/y coordinates that might be outside the SceneView’s pixel rect.
WorldToGUIPoint
discards depth information. To also get the view-space depth of the point, use HandleUtility.WorldToGUIPointWithDepth, which returns the depth in the z component of a Vector3.