# ScreenPointToRay(Camera, Vector2)

> Transforms a screen space position into a ray.

## Definition

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

```csharp
public static Ray ScreenPointToRay(Camera cam, Vector2 screenPos)
```

### Parameters

**** (\[Camera]\(/engine/6000.0/script-reference/unityengine/camera)): The camera from which the ray originates. (Optional)**** (\[Vector2]\(/engine/6000.0/script-reference/unityengine/vector2)): The screen point.

### Returns

| Type                                                      | Description                                                                                                                              |
| --------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| [Ray](/engine/6000.0/script-reference/unityengine/ray.md) | The ray going from camera through the screen point if the camera is given, or from the screen point going forward if no camera is given. |
