MaterialUIScaler

> Helper Components > MaterialUIScaler

The MaterialUIScaler is a component designed to replace or compliment Unity’s CanvasScaler and help keep track of the scene’s scaling settings.

 

 A MaterialUIScaler in the inspector.

Members

Member Type Description
ScaleFactorChangeEvent Delegate(float scaleFactor) Used as event to call when scaling is changed.
OrientationChangeEvent Delegate(Vector2 resolution) Used as event to call when orientation is changed.
OnScaleFactorChange ScaleFactorChangeEvent Called when the scaling is changed.
OnOrientationChange OrientationChangeEvent Called when the orientation is changed.
targetCanvas Canvas The Canvas that the MaterialUIScaler is targeting.
targetScaler CanvasScaler The CanvasScaler for the Canvas that the MaterialUIScaler is targeting.
matchOrientationToScreen bool Should the CanvasScaler's reference resolution be swapped between portrait and landscape when the screen is?
scaleFactor bool The scale factor of the Canvas (unlike the CanvasScaler, this works in any scaling mode).

Methods

Method Type Description
GetParentScaler static MaterialUIScaler (Transform transform)  Gets the relevant (parent) MaterialUIScaler from any given Transform.

Details

Each root Canvas that contains MaterialUI elements will need to have a MaterialUIScaler attached, as it notifies the elements of changes in scaling in a performance-friendly way.

The ‘Match Orientation To Screen’ feature is useful when designing UIs with both portait and landscape orientations, as it will flip the x and y values of the CanvasScaler’s reference resolution (applicable only in ‘Scale with screen size’ mode) to match the screen’s orientation (but not the values themselves, to preserve scaling) when a change is detected. Unless you’re handling this yourself or otherwise modify the reference resolution, it’s a good idea to keep this enabled.

It is recommended to read the documentation on Scaling Practices.