PixelsToPoints
Convert a Rect from pixel space to point space.
Read time 1 minuteLast updated 6 days ago
Definition
- Type: Method
- Namespace: UnityEditor
- Assembly: UnityEditor.CoreModule
PixelsToPoints(Rect)
Convert a Rect from pixel space to point space.
public static Rect PixelsToPoints(Rect rect)
Parameters
A GUI rect measured in pixels.
Returns
Type | Description |
|---|---|
| Rect | A rect representing the same area in points. |
Remarks
Convert from pixel space to point space.
Use this to convert values from custom content for use in GUI. For instance, you might be rendering a camera to a render texture, and then drawing GUI on top of that. Screen positions from the camera will be in pixel space, and need to be converted to points before being used for your UI.
Additional Resources: EditorGUIUtility.PointsToPixels, EditorGUIUtility.pixelsPerPoint.
PixelsToPoints(Vector2)
Convert a position from pixel to point space.
public static Vector2 PixelsToPoints(Vector2 position)
Parameters
A GUI position in pixel space.
Returns
Type | Description |
|---|---|
| Vector2 | A vector representing the same position in point space. |
PixelsToPoints(Vector2, float)
Convert from pixel space to point space.
public static Vector2 PixelsToPoints(Vector2 position, float scaling)
Parameters
Returns
Type | Description |
|---|---|
| Vector2 |
Remarks
Use this to convert values from custom content for use in GUI. For instance, you might be rendering a camera to a render texture, and then drawing GUI on top of that. Screen positions from the camera will be in pixel space, and need to be converted to points before being used for your UI.
Additional Resources: EditorGUIUtility.PointsToPixels, EditorGUIUtility.pixelsPerPoint.