Scripting API

RectTransformUtility

static class in UnityEngine · UnityEngine.UIModule

10 of 10 of Unity's membersUnity's documentation
In Tassix

Converting between screen points and RectTransforms.

Methods 10

static Bounds CalculateRelativeRectTransformBounds(Transform root, Transform child)
static Bounds CalculateRelativeRectTransformBounds(Transform trans)
static void FlipLayoutAxes(RectTransform rect, bool keepPositioning, bool recursive)
static void FlipLayoutOnAxis(RectTransform rect, int axis, bool keepPositioning, bool recursive)
static Vector2 PixelAdjustPoint(Vector2 point, Transform elementTransform, Canvas canvas)
static Rect PixelAdjustRect(RectTransform rectTransform, Canvas canvas)
static bool RectangleContainsScreenPoint(RectTransform rect, Vector2 screenPoint)
static bool RectangleContainsScreenPoint(RectTransform rect, Vector2 screenPoint, Camera? cam)
static bool RectangleContainsScreenPoint(RectTransform rect, Vector2 screenPoint, Camera? cam, Vector4 offset)

Whether the screen point, projected onto the rect's plane, falls inside it (grown by -offset: left, bottom, right, top padding).

static bool ScreenPointToLocalPointInRectangle(RectTransform rect, Vector2 screenPoint, Camera? cam, out Vector2 localPoint)
static Ray ScreenPointToRay(Camera? cam, Vector2 screenPos)

A ray from the camera through the screen point; without a camera, straight into the screen from the point.

static bool ScreenPointToWorldPointInRectangle(RectTransform rect, Vector2 screenPoint, Camera? cam, out Vector3 worldPoint)
static Vector2 WorldToScreenPoint(Camera? cam, Vector3 worldPoint)