GuiScale Class |
Namespace: KSPDev.GUIUtils
The GuiScale type exposes the following members.
Name | Description | |
---|---|---|
![]() | pivot | The pivot point to scale the dialog at. |
![]() | scale | The current scale which this control is tracking. |
Name | Description | |
---|---|---|
![]() | Finalize | Unregisters any game's callbacks. (Overrides ObjectFinalize.) |
![]() | UpdateMatrix | Updates the current GUI matrix to adjust the scale. |
Name | Description | |
---|---|---|
![]() | scaleIsDirty | Tells if the scale must be recalculated on the next access to scale. |
The scale is applied to the dialog controls by adjusting GUI.matrix, which is a global variable. It must be restored to the original value before exiting OnGUI, or else the other controls in the game will also be affected.
This control simply magnifies the dialog. The good side of it is that the original code doesn't need to be changed. The bad side is that the low-res graphics (like the controls backgrounds) may not look nice when stretched up.
GuiScale _guiScale; Rect _windowRect; void OnAwake() { _guiScale = new GuiScale(getPivotFn: () => new Vector2(_windowRect.x, _windowRect.y)); } void OnGUI() { using (new GuiMatrixScope() { _guiSkin.UpdateMatrix(); _windowRect = GUILayout.Window(GetInstanceID(), _windowRect, WindowFunc, WindowTitle); } }