Class LayerUIScale
Base class for handling quad / cylinder collider generation and maintaining aspect ratio with Canvas changes
Inherited Members
Namespace: Unity.XR.CompositionLayers .UIInteraction
Assembly: Unity.XR.CompositionLayers.UIInteraction.dll
Syntax
[ExecuteInEditMode]
public class LayerUIScale : MonoBehaviour
Fields
HeightScale
Scalar of height for transform recalculations
Declaration
public float HeightScale
Field Value
Type | Description |
---|---|
float |
WidthScale
Scalar of width for transform recalculations
Declaration
public float WidthScale
Field Value
Type | Description |
---|---|
float |
canvasRect
Reference to RectTransform to check for size or scale changes
Declaration
protected RectTransform canvasRect
Field Value
Type | Description |
---|---|
Rect |
canvasScaleX
Cached RectTransform's localScale.x
Declaration
protected float canvasScaleX
Field Value
Type | Description |
---|---|
float |
canvasScaleY
Cached RectTransform's localScale.y
Declaration
protected float canvasScaleY
Field Value
Type | Description |
---|---|
float |
canvasSizeX
Cached RectTransform's sizeDelta.x
Declaration
protected float canvasSizeX
Field Value
Type | Description |
---|---|
float |
canvasSizeY
Cached RectTransform's sizeDelta.y
Declaration
protected float canvasSizeY
Field Value
Type | Description |
---|---|
float |
texturesExtension
Reference to TexturesExtension for cropping and stretching
Declaration
protected TexturesExtension texturesExtension
Field Value
Type | Description |
---|---|
Textures |
Methods
CanvasAdjusted()
Check whether or not the canvas has changed in size or scale.
Declaration
protected bool CanvasAdjusted()
Returns
Type | Description |
---|---|
bool | Whether or not the canvas rect has been changed (size or scale) |
GetInverseUIScale()
Inverts the UI Scale from GetUIScale for inverse scaling Mainly used for the UIHandle positioning
Declaration
public Vector3 GetInverseUIScale()
Returns
Type | Description |
---|---|
Vector3 | Returns a Vector3 scalar to transform a point on a Canvas to a point on the Layer |
See Also
GetUIScale()
Calculates a Vector3 scalar to help convert a point from world space to the local space. Mainly used for the UIHandle positioning.
Declaration
public virtual Vector3 GetUIScale()
Returns
Type | Description |
---|---|
Vector3 | Returns a Vector3 scalar to transform a point on a Canvas to a point on the Layer |
UpdateDestinationRectScale(float)
Calculates the HeightScale and WidthScale based on the composition layer's aspect, the canvas size, and canvas scale.
Declaration
public void UpdateDestinationRectScale(float aspect)
Parameters
Type | Name | Description |
---|---|---|
float | aspect | Aspect ratio of Layer |