包含11節(jié)視頻教程
從零基礎(chǔ)學(xué)習(xí)unity3d游戲引擎,簡(jiǎn)單易學(xué)的視頻教程,讓你快速掌握unity3d,并喜歡上游戲開發(fā)的樂趣。
![]()
|
![]() 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ù)值即可改變字體的大。
Import Settings specific to non-dynamic fonts
Import Settings specific to dynamic fonts
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 supportUnity 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 提示
贊0 踩0 |
未知用戶
2005-2025 朱峰社區(qū) 版權(quán)所有 遼ICP備2021001865號(hào)-1
2005-2025 ZhuFeng Community All Rights Reserved
VIP