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

搜索資源 注冊(cè)|登陸

等待

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

unity3d視頻教程

unity3d視頻教程

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

從零基礎(chǔ)學(xué)習(xí)unity3d游戲引擎,簡(jiǎn)單易學(xué)的視頻教程,讓你快速掌握unity3d,并喜歡上游戲開發(fā)的樂趣。

關(guān)閉

Unity組件:Font 字體

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

Nana曉晗

普通會(huì)員

Nana曉晗

社區(qū)新人:1級(jí)

關(guān)注1844人

  • 性別

  • 年齡

    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)或文本網(wǎng)格(Text Mesh)組件創(chuàng)建或?qū)雭硎褂谩?/p>

Importing True Type Font files (.ttf) 導(dǎo)入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.

要添加一種字體到您的項(xiàng)目中,你需要將.ttf文件放到你的資源文件夾。然后Unity將自動(dòng)導(dǎo)入。你必須確保字體的擴(kuò)展名是.ttf,否則Unity不能識(shí)別。

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.

要改變字體的大小(Size?),在項(xiàng)目視圖中選中這個(gè)字體,然后在檢視面板的導(dǎo)入設(shè)置會(huì)有很多選項(xiàng)。(改變Font Size的數(shù)值即可改變字體的大。

字體的導(dǎo)入設(shè)置
Import Settings for a font 字體的導(dǎo)入設(shè)置

  • Font Size 字體大小
    The size of the font, based on the sizes set in any word processor
    字體的大小,基于任何文字處理器中設(shè)置的大小
  • 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).
    字體的文本編碼。您可以強(qiáng)制字體只有大寫或小寫字符在這里顯示,設(shè)置此模式為動(dòng)態(tài)(Dynamic),Unity會(huì)使用底層操作系統(tǒng)的字體渲染例行程序(見下文)。
  • 2.x font placing
    2.x字體鋪設(shè)
    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,使用在排字上更準(zhǔn)確的垂直字體布置,我們現(xiàn)在可以使用存儲(chǔ)在TrueType字體數(shù)據(jù)的字體上升,而不是在渲染字體紋理時(shí)計(jì)算它。選中此屬性將會(huì)使用2.x的垂直定位。

Import Settings specific to non-dynamic fonts
非動(dòng)態(tài)(non-dynamic)特有的導(dǎo)入設(shè)置(Import Settings)

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

Import Settings specific to dynamic fonts
動(dòng)態(tài)(dynamic)字體特有的導(dǎo)入設(shè)置(Import Settings)

  • Style 樣式
    The styling applied to the font, one of Normal, Bold, Italic or BoldAndItalic.
    應(yīng)用到的字體的式樣,正常(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.
    此設(shè)置控制使用動(dòng)態(tài)字體屬性時(shí)的字體的包裝。當(dāng)選上,TTF是包含在編譯輸出。未選中時(shí),它是假設(shè)最終用戶在他們的機(jī)器上已經(jīng)安裝字體。請(qǐng)注意,字體存在著版權(quán)相關(guān)約束,你應(yīng)該只包括您已獲得許可或?yàn)樽约簞?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.
    當(dāng)沒有選中包含字體數(shù)據(jù)(Include Font Data)時(shí)。輸入的字體名稱用逗號(hào)分隔的列表。這些字體將嘗試從左至右依次在玩家機(jī)器上查找,使用最先找到的那個(gè)字體。

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".

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

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

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

動(dòng)態(tài)字體是目前只支持臺(tái)式機(jī)平臺(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文本允許您顯示德國(guó),法國(guó),丹麥或日本等通常不支持ASCII字符集的字符。您還可以輸入很多不同的特殊用途字符,像箭頭標(biāo)志或選項(xiàng)的關(guān)鍵標(biāo)志,如果你的字體支持。

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字符,選擇導(dǎo)入設(shè)置字符下拉菜單為Unicode?或動(dòng)態(tài)(Dynamic?),F(xiàn)在,您可以用這種字體顯示Unicode字符。如果您使用的是GUI文本(GUIText)?或文本網(wǎng)格(?Text Mesh),您可以在檢視面板輸入U(xiǎn)nicode字符到組件的文本字段(?Text?field)。請(qǐng)注意,在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.

如果你想在腳本設(shè)置顯示的文本,您也可以使用Unicode字符。?JavaScript和C#編譯器完全支持基于Unicode的腳本。您只需將您的腳本保存為UTF - 16編碼。在Unitron中,可以通過打開腳本,并選擇文字?- >文字編碼?- >?Unicode(UTF16)(Text->Text Encoding->Unicode (UTF 16))完成,F(xiàn)在您可以在你的腳本添加Unicode字符到字符串,他們會(huì)如預(yù)期在UnityGUI,GUI文本(GUIText)或文本網(wǎng)格(Text Mesh)顯示。在PC機(jī)上,?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 圖形用戶界面文本 和 文本網(wǎng)格

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)或文本網(wǎng)格(Text Mesh),您可以通過使用一個(gè)自定義字體材質(zhì)改變其顏色。在項(xiàng)目視圖中點(diǎn)擊創(chuàng)建-?>材質(zhì)(Create->Material,),并在檢視面板選擇和設(shè)置新創(chuàng)建的材質(zhì)。確保你從字體資源為材質(zhì)指派了的紋理。如果您使用內(nèi)置的GUI /文本著色器(Text Shader)為字體材質(zhì)著色,你可以在材質(zhì)的文本顏色(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)建一個(gè)GUISkin?,并定義為特定的控制狀態(tài),例如標(biāo)簽?-?>一般?- >文字顏色(Label->Normal->Text Color)。有關(guān)詳細(xì)信息,請(qǐng)閱讀GUI皮膚頁(yè)面(GUI Skin page)。

Hints 提示
  • To display an imported font select the font and choose GameObject->Create Other->3D Text.
    要顯示導(dǎo)入的字體,選中字體和選擇游戲?qū)ο?-?>創(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.
    默認(rèn)的字體,Unity提供的是Arial。這種字體是始終可用并沒有出現(xiàn)在項(xiàng)目窗口。在編輯器中,字體被視為動(dòng)態(tài)(Dynamic?)字體,所以它包含的所有字符可以使用。然而在移動(dòng)設(shè)備上使用時(shí),默認(rèn)的字體是被視為ASCII默認(rèn)設(shè)置(ASCII Default Set)字體。這意味著,只有ASCII字符可以在移動(dòng)設(shè)備上顯示,使用此字體。例如,在移動(dòng)設(shè)備上顯示CJK字符,請(qǐng)使用自己的字體和標(biāo)記為Unicode。

贊0 踩0

未知用戶

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

VIP

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

回頂部

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