Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


ScreenPointToRay(Camera, Vector2)

Transforms a screen space position into a ray.
Read time 1 minuteLast updated 4 days ago

Definition

  • Type: Method
  • Namespace: UnityEngine
  • Assembly: UnityEngine.UIModule
public static Ray ScreenPointToRay(Camera cam, Vector2 screenPos)

Parameters

The camera from which the ray originates. (Optional)

screenPos

The screen point.

Returns

Type

Description

RayThe 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.