Added dpi specific font scaling
This commit is contained in:
31
Assets/RothenburgAR/Scripts/UI/FontsizeManager.cs
Normal file
31
Assets/RothenburgAR/Scripts/UI/FontsizeManager.cs
Normal 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
|
||||
}
|
||||
}
|
||||
13
Assets/RothenburgAR/Scripts/UI/FontsizeManager.cs.meta
Normal file
13
Assets/RothenburgAR/Scripts/UI/FontsizeManager.cs.meta
Normal 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:
|
||||
28
Assets/RothenburgAR/Scripts/UI/FontsizeSelector.cs
Normal file
28
Assets/RothenburgAR/Scripts/UI/FontsizeSelector.cs
Normal 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()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
13
Assets/RothenburgAR/Scripts/UI/FontsizeSelector.cs.meta
Normal file
13
Assets/RothenburgAR/Scripts/UI/FontsizeSelector.cs.meta
Normal 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:
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user