天天看點

Unity3D說明文檔翻譯-Visual ComponentsVisual Components

Visual Components

可視化元件

With the introduction of the UI system, new Components have been added that will help you create GUI specific functionality. This section will cover the basics of the new Components that can be created.

在UI系統介紹中,添加了新的元件,這将有助你建立GUI的特定功能.本章節将介紹可建立的新元件的基本知識.

Text

文本

The Text component, which is also known as a Label, has a Text area for entering the text that will be displayed. It is possible to set the font, font style, font size and whether or not the text has rich text capability.

文本組也被稱為标簽,有一個文本區域用于輸入将被顯示的文本.可以設定字型,字型風格,字型大小和是否有富文本性能.

There are options to set the alignment of the text, settings for horizontal and vertical overflow which control what happens if the text is larger than the width or height of the rectangle, and a Best Fit option that makes the text resize to fit the available space.

有選項來設定文本對齊方式,橫向和縱向溢出設定控制如果文本大于矩形的寬或高時将發生什麼,而最佳适配選項使文本調整大小來适應空用空間.

Image

圖檔

An Image has a Rect Transform component and an Image component. A sprite can be applied to the Image component under the Target Graphic field, and its colour can be set in the Color field. A material can also be applied to the Image component. The Image Type field defines how the applied sprite will appear, the options are:

一個圖形對象有一個矩形轉換元件和一個圖形元件.一個精靈可應用到圖形元件的圖形字段上,且它的顔色可在顔色字段上設定.材質也可以應用到圖形元件.圖形類型字段定義如何應用精靈,這些選項是:

· 

Simple - Scales the whole sprite equally.

簡單--整個精靈均等縮放

· 

Sliced - Utilises the 3x3 sprite division so that resizing does not distort corners and only the center part is stretched.

切割--使用3*3精靈分割是以調整大小不會使角變形并且僅拉伸中心部分.

· 

Tiled - Similar to Sliced, but tiles (repeats) the center part rather than stretching it. For sprites with no borders at all, the entire sprite is tiled.

平鋪--類似切割,但平鋪(重複)中心部分而不是拉伸它.如果精靈沒定義邊界則平鋪幀張精靈.

· 

Filled - Shows the sprite in the same way as Simple does except that it fills in the sprite from an origin in a defined direction, method and amount.

填充--顯示精靈方法和簡單模式一樣除了從一個原地以定義好的方向,方法和數量填充精靈.

· 

The option to Set Native Size, which is shown when Simple or Filled is selected, resets the image to the original sprite size.

設定本地大小選項是當選擇簡單或填充模式時,重置圖檔到精靈的原始大小.

Images can be imported as UI sprites by selecting Sprite( 2D / UI) from the ‘Texture Type’ settings. Sprites have extra import settings compared to the old GUI sprites, the biggest difference is the addition of the sprite editor. The sprite editor provides the option of 9-slicing the image, this splits the image into 9 areas so that if the sprite is resized the corners are not stretched or distorted.

圖檔可以通過”貼圖類型”設定選擇精靈(2D/UI)來作為UI精靈導入.精靈有額外導入設定,和老式GUI精靈相比,巨大的不同是添加了精靈編輯器.精靈編輯器提供了圖檔”9切片”方式,把圖檔分為9個區域是以如果精靈調整大小角将不會拉伸和變形.

Raw Image

原始圖像

The Image component takes a sprite but Raw Image takes a texture (no borders etc). Raw Image should only be used if necessary otherwise Image will be suitable in the majority of cases.

圖形元件帶有一個精靈但原始圖形帶有一個貼圖(沒邊界等).原始圖形将隻當需要時使用否則圖形元件适合大部分情形.

Mask

遮罩

A Mask is not a visible UI control but rather a way to modify the appearance of a control’s child elements. The mask restricts (ie, “masks”) the child elements to the shape of the parent. So, if the child is larger than the parent then only the part of the child that fits within the parent will be visible.

一個遮罩不是一個可見UI控制更确切的說是一種修改控制的子元素的外觀的方法.遮罩限制子元素相對于父對象的形狀.是以,如果子對象大于父對象則僅隻有适應在父對象上的子對象部分将可見.

Effects

效果

Visual components can also have various simple effects applied, such as a simple drop shadow or outline. See the Effects reference page for more information.

可視化元件也可以應用許多簡單的效果,諸如一個簡單的投影或輪廓.檢視”效果”參考頁面擷取更多資訊.

繼續閱讀