From c03e940847f18fb10a1a26920dd86ae55eb4d804 Mon Sep 17 00:00:00 2001 From: in0finite Date: Mon, 29 Jul 2019 18:01:19 +0200 Subject: [PATCH] font size changes with screen resolution --- Assets/Scripts/Behaviours/UIManager.cs | 7 ++++++- Docs/TODO.md | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Assets/Scripts/Behaviours/UIManager.cs b/Assets/Scripts/Behaviours/UIManager.cs index 203b384c..badae0da 100644 --- a/Assets/Scripts/Behaviours/UIManager.cs +++ b/Assets/Scripts/Behaviours/UIManager.cs @@ -31,6 +31,8 @@ namespace SanAndreasUnity.Behaviours public int ImguiFontSize { get => m_imguiFontSize; set { m_imguiFontSize = value; m_shouldChangeFontSize = true; } } [SerializeField] int m_defaultFontSizeOnMobile = 16; + [SerializeField] int m_referenceScreenHeightForFontSize = 720; + [SerializeField] int m_maxFontSize = 23; [SerializeField] bool m_changeFontSizeInEditor = false; [SerializeField] float m_scrollbarSizeMultiplierOnMobile = 2f; @@ -55,7 +57,10 @@ namespace SanAndreasUnity.Behaviours // set default font size on mobile platforms 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; } } diff --git a/Docs/TODO.md b/Docs/TODO.md index 35ea3820..17207640 100644 --- a/Docs/TODO.md +++ b/Docs/TODO.md @@ -25,7 +25,7 @@ - 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: