Class PhysicsRaycaster
Simple event system using physics raycasts.
Inheritance
Inherited Members
Namespace: UnityEngine.EventSystems
Assembly: UnityEngine.UI.dll
Syntax
[AddComponentMenu("Event/Physics Raycaster")]
[RequireComponent(typeof(Camera))]
public class PhysicsRaycaster : BaseRaycaster
Constructors
PhysicsRaycaster()
Declaration
protected PhysicsRaycaster()
Fields
kNoEventMaskSet
Const to use for clarity when no event mask is set
Declaration
protected const int kNoEventMaskSet = -1
Field Value
Type | Description |
---|---|
int |
m_EventCamera
Declaration
protected Camera m_EventCamera
Field Value
Type | Description |
---|---|
Camera |
m_EventMask
Layer mask used to filter events. Always combined with the camera's culling mask if a camera is used.
Declaration
[SerializeField]
protected LayerMask m_EventMask
Field Value
Type | Description |
---|---|
LayerMask |
m_LastMaxRayIntersections
Declaration
protected int m_LastMaxRayIntersections
Field Value
Type | Description |
---|---|
int |
m_MaxRayIntersections
The max number of intersections allowed. 0 = allocating version anything else is non alloc.
Declaration
[SerializeField]
protected int m_MaxRayIntersections
Field Value
Type | Description |
---|---|
int |
Properties
depth
Depth used to determine the order of event processing.
Declaration
public virtual int depth { get; }
Property Value
Type | Description |
---|---|
int |
eventCamera
The camera that will generate rays for this raycaster.
Declaration
public override Camera eventCamera { get; }
Property Value
Type | Description |
---|---|
Camera |
Overrides
eventMask
Layer mask used to filter events. Always combined with the camera's culling mask if a camera is used.
Declaration
public LayerMask eventMask { get; set; }
Property Value
Type | Description |
---|---|
LayerMask |
finalEventMask
Event mask used to determine which objects will receive events.
Declaration
public int finalEventMask { get; }
Property Value
Type | Description |
---|---|
int |
maxRayIntersections
Max number of ray intersection allowed to be found.
Declaration
public int maxRayIntersections { get; set; }
Property Value
Type | Description |
---|---|
int |
Remarks
A value of zero will represent using the allocating version of the raycast function where as any other value will use the non allocating version.
Methods
ComputeRayAndDistance(PointerEventData, ref Ray, ref int, ref float)
Returns a ray going from camera through the event position and the distance between the near and far clipping planes along that ray.
Declaration
protected bool ComputeRayAndDistance(PointerEventData eventData, ref Ray ray, ref int eventDisplayIndex, ref float distanceToClipPlane)
Parameters
Type | Name | Description |
---|---|---|
PointerEventData | eventData | The pointer event for which we will cast a ray. |
Ray | ray | The ray to use. |
int | eventDisplayIndex | The display index used. |
float | distanceToClipPlane | The distance between the near and far clipping planes along the ray. |
Returns
Type | Description |
---|---|
bool | True if the operation was successful. false if it was not possible to compute, such as the eventPosition being outside of the view. |
Raycast(PointerEventData, List<RaycastResult>)
Raycast against the scene.
Declaration
public override void Raycast(PointerEventData eventData, List<RaycastResult> resultAppendList)
Parameters
Type | Name | Description |
---|---|---|
PointerEventData | eventData | Current event data. |
List<RaycastResult> | resultAppendList | List of hit Objects. |