I had some trouble where on one Android, a Nexus 7, my system embeded arial font wasn't resolving and all my text was invisible. Then I found an arial.ttf font file and added it to my assets. Then all the labels in my interface lost their font setting. I was sadness.
It's easy to write something to replace all the labels with a new font at run time. But I wanted to do this in the Unity Editor. So with a little work, I came up with something. Just sharing in case someone else needs it. Perhaps it already exists? I don't know. I couldn't find one.
So to use this:
1.) create a Resource folder in your Assets folder in your project.
2.) drop a .ttf true type font file in the Resource folder
3.) paste this snippet into an empty c# script
4.)
modify this script to replace the
yourFontName with the one you want to replace. Don't include the .ttf extension.
5.) use the new menu option in MyMenu to replace all your fonts!
6.) be happiness
using System;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
public class MyMenu : MonoBehaviour
{
#if UNITY_EDITOR
// Add a menu item named "Do Something" to MyMenu in the menu bar.
[MenuItem ("MyMenu/Replace All Label Fonts")]
static void replaceAllFonts()
{
UILabel[] labels = GameObject.Find("UI Root").GetComponentsInChildren<UILabel> (true);
Debug.Log("We found :" + labels.Length + " labels.");
Font go = Resources.Load("yourFontName") as Font;
if(go == null)
Debug.LogWarning("We failed to load font.");
else
{
Debug.Log("Loaded font.");
foreach (UILabel l in labels)
{
l.trueTypeFont = go;
}
Debug.Log("success!");
}
}
#endif
}