Wanzyee Studio

Filter raycasts by the alpha and proportion inside the viewport. More...

Inherits MonoBehaviour, and ICanvasRaycastFilter.

Public Member Functions

bool IsRaycastLocationValid (Vector2 sp, Camera eventCamera)
 Check if the raycast valid, i.e., the visibility is over the threshold. More...
 

Public Attributes

RectTransform viewport
 The viewport contains this to calculate the proportion. More...
 
float threshold
 The minimum visibility to pass raycasts. More...
 
int sample = 10
 The sampling frequency to calculate the proportion when this rotates relative to the viewport. More...
 

Properties

Graphic graphic [get]
 Get the UnityEngine.UI.Graphic with this, throw exception if none. More...
 
float alpha [get]
 Get the alpha of the UnityEngine.UI.Graphic with this. More...
 
float proportion [get]
 Get the UnityEngine.RectTransform proportion inside the viewport. More...
 
float visibility [get]
 Get the visibility, i.e., the alpha multiply the proportion. More...
 

Detailed Description

Filter raycasts by the alpha and proportion inside the viewport.

Member Function Documentation

bool IsRaycastLocationValid ( Vector2  sp,
Camera  eventCamera 
)

Check if the raycast valid, i.e., the visibility is over the threshold.

Parameters
spScreen position.
eventCameraRaycast camera.
Returns
true if raycast valid; otherwise, false.

Member Data Documentation

RectTransform viewport

The viewport contains this to calculate the proportion.

float threshold

The minimum visibility to pass raycasts.

int sample = 10

The sampling frequency to calculate the proportion when this rotates relative to the viewport.

Property Documentation

Graphic graphic
get

Get the UnityEngine.UI.Graphic with this, throw exception if none.

float alpha
get

Get the alpha of the UnityEngine.UI.Graphic with this.

float proportion
get

Get the UnityEngine.RectTransform proportion inside the viewport.

Use parent UnityEngine.UI.Mask or UnityEngine.Canvas instead of viewport if not set. Or return 0 if there's none of the above.

float visibility
get

Get the visibility, i.e., the alpha multiply the proportion.

Only valid when the graphic is active and enabled in the hierarchy, otherwise return 0.