Class CanvasExtensions
Extensions for the Canvas class.
Inherited Members
Namespace: Microsoft.MixedReality.Toolkit
Assembly: cs.temp.dll.dll
Syntax
public static class CanvasExtensions
Methods
GetChildRectTransformAtPoint(RectTransform, Vector3, Boolean, Boolean, Boolean)
Gets a child rect transform for the given point and parameters.
Declaration
public static RectTransform GetChildRectTransformAtPoint(this RectTransform rectTransformParent, Vector3 worldPoint, bool recursive, bool shouldReturnActive, bool shouldReturnRaycastable)
Parameters
Type | Name | Description |
---|---|---|
RectTransform | rectTransformParent | The rect transform to look for children that may contain the projected (orthogonal to the child's normal) world point |
Vector3 | worldPoint | The world point |
Boolean | recursive | Indicates if the check should be done recursively |
Boolean | shouldReturnActive | If true, will only check children that are active, otherwise it will check all children. |
Boolean | shouldReturnRaycastable | If true, will only check children that if they have a graphic and have it's member raycastTarget set to true, otherwise will ignore the raycastTarget value. Will still allow children to be checked that do not have a graphic component. |
Returns
Type | Description |
---|---|
RectTransform |
GetChildRectTransformAtPoint(RectTransform, Vector3, Boolean, Boolean, Boolean)
Gets a child rect transform for the given point and parameters.
Declaration
public static RectTransform GetChildRectTransformAtPoint(this RectTransform rectTransformParent, Vector3 worldPoint, bool recursive, bool shouldReturnActive, bool shouldReturnRaycastable)
Parameters
Type | Name | Description |
---|---|---|
RectTransform | rectTransformParent | The rect transform to look for children that may contain the projected (orthogonal to the child's normal) world point |
Vector3 | worldPoint | The world point |
Boolean | recursive | Indicates if the check should be done recursively |
Boolean | shouldReturnActive | If true, will only check children that are active, otherwise it will check all children. |
Boolean | shouldReturnRaycastable | If true, will only check children that if they have a graphic and have it's member raycastTarget set to true, otherwise will ignore the raycastTarget value. Will still allow children to be checked that do not have a graphic component. |
Returns
Type | Description |
---|---|
RectTransform |
GetLocalCorners(Canvas)
Convenience method for getting the corners of the canvas in local coordinates. Ordered clockwise from bottom-left.
Declaration
public static Vector3[] GetLocalCorners(this Canvas canvas)
Parameters
Type | Name | Description |
---|---|---|
Canvas | canvas | The canvas to get the local corners from. |
Returns
Type | Description |
---|---|
Vector3[] | An array of Vector3s that represent the corners of the canvas in local coordinates. |
GetLocalCorners(Canvas)
Convenience method for getting the corners of the canvas in local coordinates. Ordered clockwise from bottom-left.
Declaration
public static Vector3[] GetLocalCorners(this Canvas canvas)
Parameters
Type | Name | Description |
---|---|---|
Canvas | canvas | The canvas to get the local corners from. |
Returns
Type | Description |
---|---|
Vector3[] | An array of Vector3s that represent the corners of the canvas in local coordinates. |
GetPlane(Canvas)
Convenience method for getting a plane for this canvas in world coordinates.
Declaration
public static Plane GetPlane(this Canvas canvas)
Parameters
Type | Name | Description |
---|---|---|
Canvas | canvas | The canvas to get the plane from. |
Returns
Type | Description |
---|---|
Plane | A Plane for this canvas. |
GetPlane(Canvas)
Convenience method for getting a plane for this canvas in world coordinates.
Declaration
public static Plane GetPlane(this Canvas canvas)
Parameters
Type | Name | Description |
---|---|---|
Canvas | canvas | The canvas to get the plane from. |
Returns
Type | Description |
---|---|
Plane | A Plane for this canvas. |
GetScreenCorners(Canvas)
Gets the position of the corners for a canvas in screen space. 1 -- 2 | | 0 -- 3
Declaration
public static Vector3[] GetScreenCorners(this Canvas canvas)
Parameters
Type | Name | Description |
---|---|---|
Canvas | canvas | The canvas to get the screen corners for. |
Returns
Type | Description |
---|---|
Vector3[] |
GetScreenCorners(Canvas)
Gets the position of the corners for a canvas in screen space. 1 -- 2 | | 0 -- 3
Declaration
public static Vector3[] GetScreenCorners(this Canvas canvas)
Parameters
Type | Name | Description |
---|---|---|
Canvas | canvas | The canvas to get the screen corners for. |
Returns
Type | Description |
---|---|
Vector3[] |
GetScreenRect(Canvas)
Returns a rectangle in screen coordinates that encompasses the bounds of the target canvas.
Declaration
public static Rect GetScreenRect(this Canvas canvas)
Parameters
Type | Name | Description |
---|---|---|
Canvas | canvas | The canvas the get the screen rect for |
Returns
Type | Description |
---|---|
Rect |
GetScreenRect(Canvas)
Returns a rectangle in screen coordinates that encompasses the bounds of the target canvas.
Declaration
public static Rect GetScreenRect(this Canvas canvas)
Parameters
Type | Name | Description |
---|---|---|
Canvas | canvas | The canvas the get the screen rect for |
Returns
Type | Description |
---|---|
Rect |
GetViewportCorners(Canvas)
Convenience method for getting the corners of the canvas in viewport coordinates. Note that the points have the same ordering as the array returned in GetWorldCorners()
Declaration
public static Vector3[] GetViewportCorners(this Canvas canvas)
Parameters
Type | Name | Description |
---|---|---|
Canvas | canvas | The canvas to get the viewport corners from |
Returns
Type | Description |
---|---|
Vector3[] | An array of Vector3s that represent the corners of the canvas in viewport coordinates |
GetViewportCorners(Canvas)
Convenience method for getting the corners of the canvas in viewport coordinates. Note that the points have the same ordering as the array returned in GetWorldCorners()
Declaration
public static Vector3[] GetViewportCorners(this Canvas canvas)
Parameters
Type | Name | Description |
---|---|---|
Canvas | canvas | The canvas to get the viewport corners from |
Returns
Type | Description |
---|---|
Vector3[] | An array of Vector3s that represent the corners of the canvas in viewport coordinates |
GetWorldCorners(Canvas)
Convenience method for getting the corners of the canvas in world coordinates. Ordered clockwise from bottom-left.
Declaration
public static Vector3[] GetWorldCorners(this Canvas canvas)
Parameters
Type | Name | Description |
---|---|---|
Canvas | canvas | The canvas to get the world corners from. |
Returns
Type | Description |
---|---|
Vector3[] | An array of Vector3s that represent the corners of the canvas in world coordinates. |
GetWorldCorners(Canvas)
Convenience method for getting the corners of the canvas in world coordinates. Ordered clockwise from bottom-left.
Declaration
public static Vector3[] GetWorldCorners(this Canvas canvas)
Parameters
Type | Name | Description |
---|---|---|
Canvas | canvas | The canvas to get the world corners from. |
Returns
Type | Description |
---|---|
Vector3[] | An array of Vector3s that represent the corners of the canvas in world coordinates. |
Raycast(Canvas, Vector3, Vector3, out Single, out Vector3, out GameObject)
Raycast against a canvas using a ray.
Declaration
public static bool Raycast(this Canvas canvas, Vector3 rayOrigin, Vector3 rayDirection, out float distance, out Vector3 hitPoint, out GameObject hitChildObject)
Parameters
Type | Name | Description |
---|---|---|
Canvas | canvas | The canvas to raycast against |
Vector3 | rayOrigin | The origin of the ray |
Vector3 | rayDirection | The direction of the ray |
Single | distance | The distance of the ray |
Vector3 | hitPoint | The hitpoint of the ray |
GameObject | hitChildObject | The child object that was hit or the canvas itself if it has no active children that were within the hit range. |
Returns
Type | Description |
---|---|
Boolean |
Raycast(Canvas, Vector3, Vector3, out Single, out Vector3, out GameObject)
Raycast against a canvas using a ray.
Declaration
public static bool Raycast(this Canvas canvas, Vector3 rayOrigin, Vector3 rayDirection, out float distance, out Vector3 hitPoint, out GameObject hitChildObject)
Parameters
Type | Name | Description |
---|---|---|
Canvas | canvas | The canvas to raycast against |
Vector3 | rayOrigin | The origin of the ray |
Vector3 | rayDirection | The direction of the ray |
Single | distance | The distance of the ray |
Vector3 | hitPoint | The hitpoint of the ray |
GameObject | hitChildObject | The child object that was hit or the canvas itself if it has no active children that were within the hit range. |
Returns
Type | Description |
---|---|
Boolean |