Revision for “MaterialUIScaler” created on March 8, 2017 @ 06:02:35
The MaterialUIScaler is a component designed to replace or compliment Unity's CanvasScaler and help keep track of the scene's scaling settings. <a href="http://materialunity.com/wp-content/uploads/2016/08/materialuiscaler-inspector.png" rel="attachment wp-att-142"><img class="wp-image-200 aligncenter" src="http://materialunity.com/wp-content/uploads/2016/08/materialuiscaler-inspector.png" alt="" width="742" height="650" /></a> <p style="text-align: center;"> <span style="color: #999999;"><em>A <span style="color: #999999;">MaterialUIScaler</span> in the inspector.</em></span></p> <h1>Members</h1> [table] Member,Type,Description <strong>ScaleFactorChangeEvent,</strong>Delegate(float scaleFactor),Used as event to call when scaling is changed. <strong>OrientationChangeEvent,</strong>Delegate(Vector2 resolution),Used as event to call when orientation is changed. <strong>OnScaleFactorChange,</strong>ScaleFactorChangeEvent<strong>,</strong>Called when the scaling is changed. <strong>OnOrientationChange,</strong>OrientationChangeEvent<strong>,</strong>Called when the orientation is changed. <strong>targetCanvas</strong>,Canvas,The Canvas that the MaterialUIScaler is targeting. <strong>targetScaler</strong>,CanvasScaler,The CanvasScaler for the Canvas that the MaterialUIScaler is targeting. <strong>matchOrientationToScreen</strong>,bool,Should the CanvasScaler's reference resolution be swapped between portrait and landscape when the screen is? <strong>scaleFactor</strong>,bool,The scale factor of the Canvas (unlike the CanvasScaler\, this works in any scaling mode). [/table] <h1>Methods</h1> [table] Method,Type,Description <strong>GetParentScaler</strong>, static MaterialUIScaler (Transform transform), Gets the relevant (parent) MaterialUIScaler from any given Transform. [/table] <h1>Details</h1> 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 <a href="http://materialunity.com/documentation/design-patterns-and-practices/scaling/">Scaling Practices</a>.