Class UITKPanelScale
Scales the whole interface by adjusting the shared UnityEngine.UIElements.PanelSettings reference resolution.
public static class UITKPanelScale
- Inheritance
-
UITKPanelScale
- Inherited Members
Remarks
Why the reference resolution and not PanelSettings.scale. That property
only has an effect under PanelScaleMode.ConstantPixelSize; the project's panel is
authored ScaleWithScreenSize against a 1200x800 reference matched on width, so
setting scale does nothing at all. Under that mode the reference resolution is
the scale knob: a smaller reference means each authored point covers more of the screen, so
dividing it by the multiplier makes the interface larger.
Panel positions move with it. Stored positions are in panel points, and changing the reference resolution changes how many points fit on screen — so a panel the player pushed against the right edge is off-screen at a larger scale. UITKControl re-clamps a restored position into the visible area on every layout, which is what keeps that from stranding a window; nothing here has to move them.
Restored in the editor. UnityEngine.UIElements.PanelSettings is a project asset, and a value written into it at play time stays written — a developer who ran the client once with a non-default UI scale would find the asset modified in source control. The authored reference resolution is captured before the first change and put back when play mode ends.
Properties
Current
The multiplier currently in force.
public static float Current { get; }
Property Value
Methods
Apply(float)
Sets the interface scale multiplier.
public static void Apply(float scale)
Parameters
scalefloatMultiplier of the authored size, clamped between MinimumUIScale and MaximumUIScale.
Register(PanelSettings)
Records the panel asset a control draws through, and applies the pending scale to it.
public static void Register(PanelSettings settings)
Parameters
settingsPanelSettingsThe control's UnityEngine.UIElements.PanelSettings. May be null.
Remarks
Called from every panel as it starts. The client applies its settings during boot, before any UnityEngine.UIElements.UIDocument exists, so the scale has nowhere to go at the moment it is read — the first panel to appear is what supplies the target.