Added dpi specific font scaling

This commit is contained in:
2018-08-24 18:19:09 +02:00
parent 48b57ecb80
commit ac77ee67ea
6 changed files with 118 additions and 7 deletions

View File

@@ -0,0 +1,31 @@
using RothenburgAR.Common;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace RothenburgAR.UI
{
public class FontsizeManager : Singleton<FontsizeManager>
{
private Dictionary<FontsizeClass, float> factors = new Dictionary<FontsizeClass, float>
{
{
FontsizeClass.Header, 1f
},
{
FontsizeClass.Body, 0.4f
}
};
public float GetFontsize(FontsizeClass sizeClass)
{
return Screen.dpi * factors[sizeClass];
}
}
public enum FontsizeClass
{
Header,
Body
}
}

View File

@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 78b8d14800915e84694580fb0d241681
timeCreated: 1535122456
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,28 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace RothenburgAR.UI
{
public class FontsizeSelector : MonoBehaviour
{
public FontsizeClass SizeClass = FontsizeClass.Body;
void Start()
{
var tmproText = gameObject.GetComponent<TMPro.TextMeshProUGUI>();
if (tmproText != null)
{
tmproText.enableAutoSizing = true;
tmproText.fontSizeMax = FontsizeManager.Instance.GetFontsize(this.SizeClass);
tmproText.fontSizeMin = tmproText.fontSizeMax * 0.8f;
}
}
void Update()
{
}
}
}

View File

@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 8b136c9157840904ba79e96d50f494bc
timeCreated: 1535125739
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -179,7 +179,7 @@ namespace RothenburgAR.Updater
{
//TODO check existing file for creation/alteration date to see if download is necessary
var mediaIDs = exhibit.Pois.Select(p => p.MediaId).ToList();
var mediaIDs = exhibit.Pois.Select(p => p.MediaId).Except(new List<string> { null }).ToList();
foreach (var mediaId in mediaIDs)
{

View File

@@ -699,8 +699,9 @@ GameObject:
- component: {fileID: 879338379}
- component: {fileID: 879338381}
- component: {fileID: 879338380}
- component: {fileID: 879338382}
m_Layer: 5
m_Name: UpdateMessage
m_Name: Text
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
@@ -771,8 +772,8 @@ MonoBehaviour:
m_outlineColor:
serializedVersion: 2
rgba: 4278190080
m_fontSize: 25.3
m_fontSizeBase: 10
m_fontSize: 50.35
m_fontSizeBase: 38.4
m_fontWeight: 400
m_enableAutoSizing: 1
m_fontSizeMin: 15
@@ -843,6 +844,18 @@ CanvasRenderer:
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 879338378}
--- !u!114 &879338382
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 879338378}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8b136c9157840904ba79e96d50f494bc, type: 3}
m_Name:
m_EditorClassIdentifier:
SizeClass: 1
--- !u!1 &1061370337
GameObject:
m_ObjectHideFlags: 0
@@ -1069,8 +1082,9 @@ GameObject:
- component: {fileID: 1940905981}
- component: {fileID: 1940905983}
- component: {fileID: 1940905982}
- component: {fileID: 1940905984}
m_Layer: 5
m_Name: HeaderText
m_Name: Text
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
@@ -1140,8 +1154,8 @@ MonoBehaviour:
m_outlineColor:
serializedVersion: 2
rgba: 4278190080
m_fontSize: 74.25
m_fontSizeBase: 36
m_fontSize: 185.6
m_fontSizeBase: 96
m_fontWeight: 400
m_enableAutoSizing: 1
m_fontSizeMin: 18
@@ -1212,6 +1226,18 @@ CanvasRenderer:
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1940905980}
--- !u!114 &1940905984
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1940905980}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8b136c9157840904ba79e96d50f494bc, type: 3}
m_Name:
m_EditorClassIdentifier:
SizeClass: 0
--- !u!1 &1981763282
GameObject:
m_ObjectHideFlags: 0