Unity3d UI NGUI對象、腳本、參數

Unity3D NGUI

對象
1.2D Root: UI的界面入口點。掛載相關控件
2.Camera: 攝像機
3.Anchor: 錨點
4.Panel: 面板,用來放置控件
5.atlas: 圖像集。可以自己編輯
6.Font: 字體
7.sprite: 
a.Depth 深度,顯示先後順序設定用的(對於Texture無效哦)
Script:
UISpriteAnimation 進行精靈動畫

8.Sliced Sprite: a sprite using 9-slicing, ideal for creating borders
9.TiledSprite: 會自動多個Tiled填充設置的Scale範圍
10.FilledSprite: a sprite that has an extra parameter that controls how much of it is visible — ideal for progress bars and sliders
11.Button: 按鍵.其實類似於Sprite+Label+Collision發出事件。還有一系列的腳本可以使用,如下。具體參考同級目錄下的UIButtonXXX
Script
a.UIButtonColor changes the color of the button when it’s hovered over or pressed on.
b.UIButtonScale enlarges the button when the mouse hovers over it.
c.UIButtonOffset moves the button toward the bottom-right corner when it’s pressed on.
d.UIButtonSound plays a sound when the button gets clicked on.

Event:
void OnHover (bool isOver) – Sent out when the mouse hovers over the collider or moves away from it. Not sent on touch-based devices.
void OnPress (bool isDown) – Sent when a mouse button (or touch event) gets pressed over the collider (with ‘true’) and when it gets released (with ‘false’, sent to the same collider even if it’s released elsewhere).
void OnClick() — Sent to a mouse button or touch event gets released on the same collider as OnPress. UICamera.currentTouchID tells you which button was clicked.
void OnDoubleClick () — Sent when the click happens twice within a fourth of a second. UICamera.currentTouchID tells you which button was clicked.
void OnSelect (bool selected) – Same as OnClick, but once a collider is selected it will not receive any further OnSelect events until you select some other collider.
void OnDrag (Vector2 delta) – Sent when the mouse or touch is moving in between of OnPress(true) and OnPress(false).
void OnDrop (GameObject drag) – Sent out to the collider under the mouse or touch when OnPress(false) is called over a different collider than triggered the OnPress(true) event. The passed parameter is the game object of the collider that received the OnPress(true) event.
void OnInput (string text) – Sent to the same collider that received OnSelect(true) message after typing something. You likely won’t need this, but it’s used by UIInput
void OnTooltip (bool show) – Sent after the mouse hovers over a collider without moving for longer than tooltipDelay, and when the tooltip should be hidden. Not sent on touch-based devices.
void OnScroll (float delta) is sent out when the mouse scroll wheel is moved.
void OnKey (KeyCode key) is sent when keyboard or controller input is used.
12.Slider: 滾軸。由背景Background,前端滾動條Foreground,滾動條頭組成Thumb
使用的時候如果修改了UISlider的Size需要對應的修改Collider的size Center還有BackGround的size  center


13.CheckBox: 選擇空間。可以通過設置EmptyObject,並設置Radio Button Root來使得組單選功能
Script: 以下腳本可以控制該功能是否啓用
a.UICheckboxControlledComponent
b.UICheckboxControlledObject

14.UIInput: 聊天空間。Sprite和Label的組合。可以響應OnInput事件觸發聊天輸入


15.3D: 與2D的區別在於Camera使用Perspective視角,Panel直接在UI Root下,沒有Anchor級別
Script:
a.PanWithMouse: 在camera中使用,滑動控件

16.UICursor: 焦點(鼠標點)

腳本:
1.UIRoot: 調節使用該腳本的對象的size爲2/屏幕高度。This script rescales the object it’s on to be 2/ScreenHeight in size, letting you specify widget coordinates in pixels and still have them be relatively small when compared to the rest of your game world.
2.UICamera: 包含NGUI的事件系統
3.UIAnchor: 調節空間位置到界面相應位置,使得控件位置具有像素自適應性
4.UIPanel: 用來控制所包含的控件,減少繪圖次數
5.PanWithMouse: 使得對象隨着鼠標移動移動,並適當轉向(面朝鏡頭的感覺)
6.UIButtonXXX: Button功能使用的腳本
7.UICheckboxControlledXXX: CheckBox使用的腳本
8.SpinWithMouse: 隨着鼠標拖動(滑動),轉向
9.ItemDatabase: 物品數據庫管理器。可以編輯時使用。目前不知道原理
10.UISpriteAnimation: 在Sprite中使用,進行精靈動畫
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章