朱峰社區(qū)首頁 朱峰社區(qū)

搜索資源 注冊|登陸

等待

返回 展開菜單
按功能 按軟件

Unity3D游戲制作教程

Unity3D游戲制作教程

包含5節(jié)視頻教程

本系列包含Unity3D介紹、Unity3D導出人物、Unity3D導出場景、Unity3D導出動作、游戲測試最終完成一個簡單的游戲。是一套非常完整的Unity3D游戲制作教程。

關閉

Unity組件:Font 字體

關注:844 留言:0 樓主:Nana曉晗 發(fā)帖時間:15年11月16日

Nana曉晗

普通會員

Nana曉晗

社區(qū)新人:1級

關注1992人

  • 性別

  • 年齡

    18

  • 積分

    1

  • 登陸

    1

  • 發(fā)帖

    1

間隔線

Fonts can be created or imported for use in either the GUI Text or the Text Mesh Components.

字體可以在GUI文本(GUI Text)或文本網格(Text Mesh)組件創(chuàng)建或導入來使用。

Importing True Type Font files (.ttf) 導入True Type字體文件(.ttf)

To add a font to your project you need to place the .ttf file in your Assets folder. Unity will then automatically import it. You have to make sure that the font has a .ttf extension otherwise Unity will not recognize it.

要添加一種字體到您的項目中,你需要將.ttf文件放到你的資源文件夾。然后Unity將自動導入。你必須確保字體的擴展名是.ttf,否則Unity不能識別。

To change the Size of the font, highlight it in the Project View and you have a number of options in the Import Settings in the Inspector.

要改變字體的大。⊿ize?),在項目視圖中選中這個字體,然后在檢視面板的導入設置會有很多選項。(改變Font Size的數(shù)值即可改變字體的大。

字體的導入設置
Import Settings for a font 字體的導入設置

  • Font Size 字體大小
    The size of the font, based on the sizes set in any word processor
    字體的大小,基于任何文字處理器中設置的大小
  • Character 字符
    The text encoding of the font. You can force the font to display only upper- or lower-case characters here Setting this mode to Dynamic causes Unity to use the underlying OS font rendering routines (see below).
    字體的文本編碼。您可以強制字體只有大寫或小寫字符在這里顯示,設置此模式為動態(tài)(Dynamic),Unity會使用底層操作系統(tǒng)的字體渲染例行程序(見下文)。
  • 2.x font placing
    2.x字體鋪設
    Unity 3.x uses a more typographically correct vertical font placement compared to 2.x. We now use the font ascent stored in the truetype font data rather than computing it when we render the font texture. Ticking this Property causes the 2.x vertical positioning to be used.
    Unity 3.x相比起2.x,使用在排字上更準確的垂直字體布置,我們現(xiàn)在可以使用存儲在TrueType字體數(shù)據(jù)的字體上升,而不是在渲染字體紋理時計算它。選中此屬性將會使用2.x的垂直定位。

Import Settings specific to non-dynamic fonts
非動態(tài)(non-dynamic)特有的導入設置(Import Settings)

  • Font Rendering 字體渲染
    The amount of anti-aliasing applied to the font.
    應用的字體,消除鋸齒的的數(shù)量

Import Settings specific to dynamic fonts
動態(tài)(dynamic)字體特有的導入設置(Import Settings)

  • Style 樣式
    The styling applied to the font, one of Normal, Bold, Italic or BoldAndItalic.
    應用到的字體的式樣,正常(Normal),粗體(Bold),斜體(Italic)或斜粗體(BoldAndItalic)。
  • Include Font Data
    包含字體數(shù)據(jù)
    This setting controls the packaging of the font when used with Dynamic font property. When selected the TTF is included in the output of the build. When not selected it is assumed that the end user will have the font already installed on their machine. Note that fonts are subject to copyright and you should only include fonts that you have licensed or created for yourself.
    此設置控制使用動態(tài)字體屬性時的字體的包裝。當選上,TTF是包含在編譯輸出。未選中時,它是假設最終用戶在他們的機器上已經安裝字體。請注意,字體存在著版權相關約束,你應該只包括您已獲得許可或為自己創(chuàng)造的字體
  • Font Names
    字體名
    Only available when Include Font Data is not selected. Enter a comma-separated list of font names. These fonts will be tried in turn from left to right and the first one found on the gamers machine will be used.
    當沒有選中包含字體數(shù)據(jù)(Include Font Data)時。輸入的字體名稱用逗號分隔的列表。這些字體將嘗試從左至右依次在玩家機器上查找,使用最先找到的那個字體。

After you import the font, you can expand the font in Project View to see that it has auto-generated some assets. Two assets are created during import: "font material" and "font texture".

在導入的字體后,你可以在項目視圖中展開字體,看到它自動生成的部分資源。兩個資源在導入過程中創(chuàng)建:"字體材質(font material)"和"字體紋理(font texture)"。

Dynamic fonts 動態(tài)字體

Unity 3.0 adds support for dynamic font rendering. When you set the Characters drop-down in the Import Settings to Dynamic, Unity will not pre-generate a texture with all font characters. Instead, it will use the OS built-in font rendering to create the texture on the fly. This has the advantage that it can save in download size and texture memory, especially when you are using a font which is commonly included in user systems, so you don't have to include the font data, or when you need to support asian languages or large font sizes (which would make the font textures very large using normal font textures). It has the disadvantage that font rendering may not look exactly the same on all user machines (especially between mac and windows machines, or when a font is not installed and a fallback font is used), and that it can occasionally cause slowdowns as the font textures are generated for the characters needed on screen.

Unity 3.0增加了支持動態(tài)字體渲染。當你在導入設置的字符(Characters?)下拉菜單設置為動態(tài)(Dynamic),Unity將不會預先生成一個與所有字體的字符紋理。相反,它會使用操作系統(tǒng)內置的字體渲染實時來創(chuàng)建的紋理。這樣做的好處,它可以保存下載的大小和紋理內存,尤其是當你使用通常在用戶系統(tǒng)中的字體,所以你不必包括字體的數(shù)據(jù),或當你需要支持亞洲語言或較大的字體大。ㄊ褂谜W煮w紋理,使字體的紋理非常大)。它的缺點,字體渲染未必所有的用戶機器上看起來完全是相同的(尤其是Mac和Windows計算機之間,或當一個字體未安裝和使用一個備用的字體),并且,在生成屏幕上所需要的字符字體紋理,有時可能會導致速度變慢。

Dynamic fonts are currently only supported on Desktop platforms (Mac and Windows).

動態(tài)字體是目前只支持臺式機平臺(Mac和Windows)。

Unicode support

Unity has full unicode support. Unicode text allows you to display German, French, Danish or Japanese characters that are usually not supported in an ASCII character set. You can also enter a lot of different special purpose characters like arrow signs or the option key sign, if your font supports it.

Unity有完整的Unicode支持。?Unicode文本允許您顯示德國,法國,丹麥或日本等通常不支持ASCII字符集的字符。您還可以輸入很多不同的特殊用途字符,像箭頭標志或選項的關鍵標志,如果你的字體支持。

To use unicode characters, choose either Unicode or Dynamic from the Characters drop-down in the Import Settings. You can now display unicode characters with this font. If you are using a GUIText or Text Mesh, you can enter unicode characters into the Component's Text field in the Inspector. Note that the Inspector on Mac may not show the unicode characters correctly.

要使用Unicode字符,選擇導入設置字符下拉菜單為Unicode?或動態(tài)(Dynamic?),F(xiàn)在,您可以用這種字體顯示Unicode字符。如果您使用的是GUI文本(GUIText)?或文本網格(?Text Mesh),您可以在檢視面板輸入Unicode字符到組件的文本字段(?Text?field)。請注意,在Mac上檢視面板可能不能正確顯示Unicode字符。

You can also use unicode characters if you want to set the displayed text from scripting. The Javascript and C# compilers fully support Unicode based scripts. You simply have to save your scripts with UTF-16 encoding. In Unitron, this can be done by opening the script and choosing Text->Text Encoding->Unicode (UTF 16). Now you can add unicode characters to a string in your script and they will display as expected in UnityGUI, a GUIText, or a Text Mesh. On the PC where UniSciTE is used for script editing save scripts using the UCS-2 Little Endian encoding.

如果你想在腳本設置顯示的文本,您也可以使用Unicode字符。?JavaScript和C#編譯器完全支持基于Unicode的腳本。您只需將您的腳本保存為UTF - 16編碼。在Unitron中,可以通過打開腳本,并選擇文字?- >文字編碼?- >?Unicode(UTF16)(Text->Text Encoding->Unicode (UTF 16))完成,F(xiàn)在您可以在你的腳本添加Unicode字符到字符串,他們會如預期在UnityGUI,GUI文本(GUIText)或文本網格(Text Mesh)顯示。在PC機上,?UniSciTE?是用于編輯腳本保存腳本,使用UCS- 2?Little Endian編碼。

Changing Font Color 改變字體顏色

There are different ways to change the color of your displayed font, depending on how the font is used.

有不同的方式來改變字體顯示顏色,這取決于如何使用字體。

GUIText & Text Mesh 圖形用戶界面文本 和 文本網格

If you are using a GUIText or a Text Mesh, you can change its color by using a custom Material for the font. In the Project View, click on Create->Material, and select and set up the newly created Material in the Inspector. Make sure you assign the texture from the font asset to the material. If you use the built-in GUI/Text Shader shader for the font material, you can choose the color in the Text Color property of the material.

如果您使用的是圖形用戶界面文本(GUIText)或文本網格(Text Mesh),您可以通過使用一個自定義字體材質改變其顏色。在項目視圖中點擊創(chuàng)建-?>材質(Create->Material,),并在檢視面板選擇和設置新創(chuàng)建的材質。確保你從字體資源為材質指派了的紋理。如果您使用內置的GUI /文本著色器(Text Shader)為字體材質著色,你可以在材質的文本顏色(Text Color)屬性選擇顏色。

UnityGUI 圖形用戶界面

If you are using UnityGUI scripting to display your font, you have much more control over the font's color under different circumstances. To change the font's color, you create a GUISkin from Assets->Create->GUI Skin, and define the color for the specific control state, e.g. Label->Normal->Text Color. For more details, please read the GUI Skin page.

如果您使用的是Unity圖形用戶界面(UnityGUI)腳本來顯示您的字體,你可以控制更多不同的情況下字體的顏色。要更改字體的顏色,從資源 -?>創(chuàng)建?- >圖形用戶界面皮膚(GUISkin)(Assets->Create->GUI Skin)創(chuàng)建一個GUISkin?,并定義為特定的控制狀態(tài),例如標簽?-?>一般?- >文字顏色(Label->Normal->Text Color)。有關詳細信息,請閱讀GUI皮膚頁面(GUI Skin page)。

Hints 提示
  • To display an imported font select the font and choose GameObject->Create Other->3D Text.
    要顯示導入的字體,選中字體和選擇游戲對象?-?>創(chuàng)建其他 - >3D文本(GameObject->Create Other->3D Text.)。
  • Using only lower or upper case characters reduces generated texture size.
    使用僅小寫或大寫字符能降低生成紋理大小。
  • The default font that Unity supplies is Arial. This font is always available and does not appear in the Project window. On the editor this font is treated as a Dynamic font so all characters it contains can be used. When used on a mobile device, however, this default font is treated as an ASCII Default Set font. This means that only ASCII characters can be displayed using this font on the mobile devices. To display, for example, CJK characters on the mobile devices please use your own font and mark it as Unicode.
    默認的字體,Unity提供的是Arial。這種字體是始終可用并沒有出現(xiàn)在項目窗口。在編輯器中,字體被視為動態(tài)(Dynamic?)字體,所以它包含的所有字符可以使用。然而在移動設備上使用時,默認的字體是被視為ASCII默認設置(ASCII Default Set)字體。這意味著,只有ASCII字符可以在移動設備上顯示,使用此字體。例如,在移動設備上顯示CJK字符,請使用自己的字體和標記為Unicode。

贊0 踩0

未知用戶

2005-2025 朱峰社區(qū) 版權所有 遼ICP備2021001865號-1
2005-2025 ZhuFeng Community All Rights Reserved

VIP

朱峰社區(qū)微信公眾號

回頂部

1.復制文本發(fā)給您的QQ好友或群、微信等;好友點擊鏈接以后,轉發(fā)就成功了。 2.如朋友點擊您的鏈接,您需要需刷新一下才行;同一個好友僅能點擊一次。
購買VIP,觀看所有收費教程。