Set default font for Text labels

How can I set default font (I have a .ttf in the Project) for all new Text elements I add to the Hierarchy? I don’t want to set the font for each Text I create - this is not good at project start AND it’s not good because you just can’t change the font project way just like that, you have to find all Text objects in the editor and change them one by one.

(Unity 4.6)

Even older question now, but I got around this by making prefabs with the default values I want. Then you can just drop them into your scene. This can also end up helping you if you want to change the font for all your Text objects… or realize you need to resize all your 28 size text to 26 or something. You can also unpack the prefab after you deploy the object if you don’t want a linkage. Doesn’t require any scripting or assets.

I’ve answered the exact similar question before on UA: Change All (new) UI Text Font?

The answer goes as below with slight modifications:

There is no straight forward way of doing it but you can write a script to do it for you which works as below.

  • Get all the child game objects of your Canvas game object. If multiple canvases are there then get child game objects of all those canvases.
  • Then traverse through all the child game objects to check to see if the game object has a Text component attached to it.
  • If there is a Text component attached you can access the font variable and set its value to the font you want.

You can also write an editor script to perform this task for you or use ExecuteInEditMode as per your convenience.

I know it’s an old question but if you don’t want to go through the hassle of creating a custom script you can get the asset we made that has that functionality and other helpful functions to help you save time.

check it out if you are interested: It’s called Gamestrap UI