font size changes with screen resolution

This commit is contained in:
in0finite 2019-07-29 18:01:19 +02:00
parent 2f9c78bd6f
commit c03e940847
2 changed files with 7 additions and 2 deletions

View file

@ -31,6 +31,8 @@ namespace SanAndreasUnity.Behaviours
public int ImguiFontSize { get => m_imguiFontSize; set { m_imguiFontSize = value; m_shouldChangeFontSize = true; } } public int ImguiFontSize { get => m_imguiFontSize; set { m_imguiFontSize = value; m_shouldChangeFontSize = true; } }
[SerializeField] int m_defaultFontSizeOnMobile = 16; [SerializeField] int m_defaultFontSizeOnMobile = 16;
[SerializeField] int m_referenceScreenHeightForFontSize = 720;
[SerializeField] int m_maxFontSize = 23;
[SerializeField] bool m_changeFontSizeInEditor = false; [SerializeField] bool m_changeFontSizeInEditor = false;
[SerializeField] float m_scrollbarSizeMultiplierOnMobile = 2f; [SerializeField] float m_scrollbarSizeMultiplierOnMobile = 2f;
@ -55,7 +57,10 @@ namespace SanAndreasUnity.Behaviours
// set default font size on mobile platforms // set default font size on mobile platforms
if (Application.isMobilePlatform || (m_changeFontSizeInEditor && Application.isEditor)) if (Application.isMobilePlatform || (m_changeFontSizeInEditor && Application.isEditor))
{ {
this.ImguiFontSize = m_defaultFontSizeOnMobile; int fontSize = Mathf.RoundToInt( m_defaultFontSizeOnMobile / (float) m_referenceScreenHeightForFontSize * Screen.height );
if (fontSize > m_maxFontSize)
fontSize = m_maxFontSize;
this.ImguiFontSize = fontSize;
} }
} }

View file

@ -25,7 +25,7 @@
- Chat - Chat
- Android: set font size to 23 ; adapt UI: Utilities size, vehicle spawner button width ; sliders should be larger ; camera zoom should be configurable (no need for persistence) ; use unsigned (debug) key alias ; increment build number ; test at 800x480 resolution ; - Android: adapt UI: Utilities size ; use unsigned (debug) key alias ; increment build number ; test at 800x480 resolution ; time scale affects physics update rate setting ;
- Touch input: - Touch input: