WorldToLocal
Transforms a point from panel coordinates into the local space of the element.
Read time 1 minuteLast updated 10 days ago
Definition
- Type: Method
- Namespace: UnityEngine.UIElements
- Assembly: UnityEngine.UIElementsModule
WorldToLocal(VisualElement, Vector2)
Transforms a point from panel coordinates into the local space of the element.
public static Vector2 WorldToLocal(this VisualElement ele, Vector2 p)
Parameters
The element to use as a reference for the local space.
The point to transform, in panel coordinates.
Returns
Type | Description |
|---|---|
| Vector2 | A point in the local space of the element. |
Remarks
Attach the element to a panel. The element must have a valid _layout. Otherwise, this method might return invalid results.
If the element's transform contains 3D information, use to get a proper 3D transformation.
ele.worldTransform.inverse.MultiplyPoint3x4(p)WorldToLocal(VisualElement, Rect)
Transforms a rectangle from panel coordinates into the local space of the element.
public static Rect WorldToLocal(this VisualElement ele, Rect r)
Parameters
The element to use as a reference for the local space.
The rectangle to transform, in panel coordinates.
Returns
Type | Description |
|---|---|
| Rect | A rectangle in the local space of the element. |
Remarks
Attach the element to a panel. The element must have a valid _layout. Otherwise, this method might return invalid results.