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中使用,进行精灵动画
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章