# WorldToLocal

> Transforms a point from the world space to the local space of the element.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine.UIElements](/engine/6000.0/script-reference/unityengine/uielements.md)
* **Assembly:** UnityEngine.UIElementsModule

## WorldToLocal(VisualElement, Vector2)

Transforms a point from the world space to the local space of the element.

```csharp
public static Vector2 WorldToLocal(this VisualElement ele, Vector2 p)
```

### Parameters

**** (\[VisualElement]\(/engine/6000.0/script-reference/unityengine/uielements/visualelement)): The element to use as a reference for the local space.**** (\[Vector2]\(/engine/6000.0/script-reference/unityengine/vector2)): The point to transform, in world space.

### Returns

| Type                                                              | Description                                |
| ----------------------------------------------------------------- | ------------------------------------------ |
| [Vector2](/engine/6000.0/script-reference/unityengine/vector2.md) | A point in the local space of the element. |

### Remarks

This element needs to be attached to a panel and must have a valid [VisualElement.layout](/engine/6000.0/script-reference/unityengine/uielements/visualelement/layout.md). Otherwise, this method might return invalid results.

## WorldToLocal(VisualElement, Rect)

Transforms a rectangle from the world space to the local space of the element.

```csharp
public static Rect WorldToLocal(this VisualElement ele, Rect r)
```

### Parameters

**** (\[VisualElement]\(/engine/6000.0/script-reference/unityengine/uielements/visualelement)): The element to use as a reference for the local space.**** (\[Rect]\(/engine/6000.0/script-reference/unityengine/rect)): The rectangle to transform, in world space.

### Returns

| Type                                                        | Description                                    |
| ----------------------------------------------------------- | ---------------------------------------------- |
| [Rect](/engine/6000.0/script-reference/unityengine/rect.md) | A rectangle in the local space of the element. |

### Remarks

This element needs to be attached to a panel and must receive a valid [VisualElement.layout](/engine/6000.0/script-reference/unityengine/uielements/visualelement/layout.md). Otherwise, this method may return invalid results.
