Game design consists of many elements that must complement each other. Even if your idea is great and the game is wacky fun to play, poor text can spoil the overall gaming experience for the audience. So, it is important to use the proper font that fits the theme of your gameplay. Not to mention, the font of your text should be legible above all else.
Unity comes with a wide variety of font collection. But sometimes you need a little extra which may not be available in Unity’s library. If that is the case, you should download new fonts online. You may also create custom fonts on a separate software (or within Unity itself).
This article will guide you how to add fonts to Unity. But first, you should know a little about the game-building software.
What is Unity?
Unity is a gaming engine designed to operate on multiple platforms. Developed by Unity Technologies, the gaming engine was first released in 2005 at Apple Inc.’s Worldwide Developer Conference. Unity was initially an Apple (Mac OS) exclusive software. Gradually, the gaming engine has extended support to a variety of platforms like mobile, gaming console, desktop and virtual reality.
The gaming engine is most popular in the iOS and Android mobile game development. It is a favorite of Indie game developers and can be used for creating both 2D and 3D games. Some major games made using the Unity engine are Call of Duty: Mobile, Pokemon Go, Cuphead, Beat Saber and Monument Valley. Unity is easy to pick up for beginner developers. Apart from video games, the unity engine has been adopted by other industries like architecture, automotive, film, construction, engineering and the United States Armed Forces.
How does Unity Work?
Users have the ability to create games and experiences in both 2D and 3D. The primary scripting API offered in Unity is C#. This applies to the Unity editor in the form of plug-ins and games, and also as drag and drop functionality. In the initial versions of the engine, Unity supported Boo as the primary programming language. With the release of Unity 5, C# was adopted as the new language.
For 2D games, users can import sprites and use Unity’s advanced 2D renderer for various projects. For 3D games, Unity offers many features like specification of texture compressions, mini maps and resolution settings for every platform supported by the game engine. It also provides support for reflection mapping, bump mapping, screen space ambient occlusion (SSAO) and parallax mapping. Users can create dynamic shadows in their games using render-to-texture, shadow maps and full-screen post-processing effects.
How to Add Fonts to Unity – Step-By-Step Instructions
You can create or import fonts to Unity in either the Text Mesh or GUI Text components. Many people use default fonts available in Unity for their games. But if you want to stand out and make an attractive game, it is better to import unique fonts that go with the theme of your game.
Here are the steps to import fonts to Unity –
Using the Drag and Drop Method
- Go to the menu tab and click on “GameObject”. A drop-down menu will appear.
- Drag your mouse cursor to “Create Other”. This will open a window beside the drop-down menu.
- Now select the type of text you want. For example, click on the “3D Text” option to write a text in 3D.
- Go to the “Inspector” panel on the right of the screen.
- Under the “Inspector” panel, look for “Text Mesh” and the option “Text” under it.
- Now write you text in the space against the “Text” option.
- You can adjust the position of the text and increase its size. To do so, look for the option “Font Size” under the “Text Mesh” box.
- Next, open the folder where you have saved new fonts (or the font that you want to import to Unity). You can download Font styles from the internet, or create custom fonts on software like Adobe Illustrator.
- Click on that font file and drag it with your mouse (keep pressing down the left mouse button).
- Drag the file all the way to Unity’s window. Drop it in the “Project” panel on the Unity Window.
- The file will appear on the “Project Panel”.
- Now grab the font file on the “Project Panel” and drag it to the “Hierarchy” panel.
- Under the “Hierarchy” panel, look for the text file. It may be named as “New Text” if you have not changed the name.
- Drag and drop the new font file on the “New Text” file.
- You will notice that your text would have automatically changed to the new font.
Using the Asset Folder
- Download or create custom fonts you want to add to Unity.
- Now visit the “Project Window” and open the project folder to which you want to add new fonts.
- A default project folder contains the following sub-folders – Assets, Library, Obj and ProjectSettings.
- Open the Assets folder.
- Drag and drop or copy-paste the new font files in the Assets folder.
- Now go to the Unity Project Explorer and right click on the newly imported font.
- A side menu will appear. Click on “Create”, then click on “TextMeshPro” and select “Font Asset”.
- This will enable you to use the new font with your TextMeshPro text.
Tips to Add Fonts to Unity
- You can easily download new TrueType fonts for free from sites like 1001freefonts.com.
- In case you want to script the text properly, try adding line breaks by inserting “/n” (escape character) in your string.
- You can style Text Meshes using a simple mark up.
- The Unity software renders fonts by first rendering the font glyphs to a texture map. For example, if the size of the font is too small then the font textures will appear blocky. Text Mesh assets use quads for rendering. If the size of the Text Mesh and Font Texture are different from each other, then the Text Mesh will look wrong.
Using Custom Fonts in Unity
To use custom fonts in Unity, simply follow these steps –
- Create a new project on Unity.
- Save the Scene using CTRL + S and name it according to your project.
- Download free fonts from the internet (you can visit sites like dafont.com). The font file will be in the TrueType Font (.ttf) Format.
- In the “Assets” folder, create a new folder called “Fonts”. Drag and drop the downloaded font file (in .ttf format) into this folder.
- Go to the “Camera” settings and adjust the size to ‘8’.
- Now go to the “Hierarchy” panel and click on “Create”.
- A drop menu will appear. Look for “UI” and bring your mouse over it. This will open another menu on the side. Now look for “Text” and click on it.
- Return to “Hierarchy” and click on the “Canvas” option. Within the “Canvas” option select your “Render” and set the “Render Mode”.
- Lastly, click on “Text” again and change its settings as per your requirement. For example, play with options like Font, Text, Max Size, Best Fit and more.
Creating Custom Fonts
If you wish to create a custom font, go to the project window and click on “Create” then select the option “Custom Font”. This will add a custom font asset to your project library.
You will find many fields under the “Inspector” panel to customize your font. Here is what the fields /elements mean –
- Ascii Start Offset – This field defines the Ascii index that you would like to start your Character Rects index from. The value in this field is put in decimals. To give you an idea – if your Ascii Start Offset is valued at ‘0’ then the capital letter (say ‘A’ for example) will be at index 65. Similarly, if you set the Ascii Start Offset at ‘65’, the letter ‘A’ will be at index ‘0’.
- Kerning – This field decides the space between individual characters. Use this to determine how close each character will be to the adjacent characters on the same line.
- Line Spacing – This field decides the space between 2 consecutive lines.
- Default Material – To create a new font, you have to import the new font in the form of a texture and then apply that texture to a material. The font material is then dragged and dropped onto the Default Material section.
- Character Rects – This is the field where you define each character of your font. Within the Character Rect field, you have options to play with. The Size field defines the number of characters that are in your font. The Element field is further divided into index fields for inputting the Ascii index of the character. You can set the UV value, which is an array of vectors whose values range between (0,0) and (1,1). Then you have the Vert size field, which is based on the pixel size of the characters. Lastly, there is the Width field, which will define the width of your character in pixels.