User Tools

Site Tools


global:fonts

Table of Contents

Fonts

(Deprecated after 1.6 update. See Global Options -> GUI Options)

You can save different prefabs storing different font files to your project. This allows you to have custom fonts ready to be used in your project. Click in one of the font prefabs provided for an example. Currently, these examples use GUIText, but you can use other tools (like NGUI) to achieve your desired font effect. All GUI scripts are open source in UFE regardless of the version. If you are intending to build your own GUI scripts, you may choose to ignore this completely.

Font ID: Sets the font ID so it can be accessed by its id through code.

Font Prefab: The Game Object Prefab containing a GUIText


How to create a new font

Inside .\UFE\GUI\Fonts\ you will find 5 examples of Font folders. Each folder contains 5 different group of font files. In order to create these files follow these procedures:

  • Create a new font folder (name it anything you want) and drag your font file here.
  • Click on the font and check the Inspector. Click on Character and select the Unicode option.
  • Change the size to your liking.
  • Click under the little wheel on the top right of the inspector window and click Create Editable Copy:

  • This will create a copy of this font, a material and a texture to this font with “_copy” on its name. Delete the copy of the font file and remove the “_copy” from the name of the other created files (organization purpose).
  • (Optional) Using Photoshop, edit the texture as you please (add stroke, change colors, add gradient, etc)
  • Click on the texture file and select GUI as its Texture Type.
  • Click on the material file and on the Inspector, select the Shader GUI/Alpha Enabled (this shader comes with all versions of UFE).
  • Under the Hierarchy, click Create → GUI Text. Rename it as the name of your font or just “Font_X” (X being the font sequence).
  • Drag your font file into the Font field.
  • Drag your Material under the Material field.
  • Notice you can't edit the font size through here. That's because you are using the Unicode System. With the Unicode you can edit your texture so the font has your unique style. If the font is too big or to small you can use the Scale option under Transform. Notice that this will not work well with any font and you might end up with different scale numbers (as shown on .UFE\GUI\Fonts\Font1_Prefab).
  • Drag the created GameObject to the font folder to create a prefab.
  • Under Global Editor, select Fonts and click “New Font”.
  • Drag the newly created prefab here.
  • Select the new Font ID (sequential).
  • You can now select the new font under Game GUI Options.

Code access:

UFE.config.fontOptions

Code example:

FontOptions fontOptions = UFE.GetFont(FontId.Font1);
GameObject guiTextGO = (GameObject)Instantiate(fontOptions.fontPrefab, Vector3.zero, Quaternion.identity);
guiTextGO.guiText.text = "Hello World!";

< Back to Global Editor

global/fonts.txt · Last modified: 2015/05/15 03:59 by Daniel E.