NGUI 由Empty创建Button

unity3d的控件是由Component组合产生的。

而不像cocos2d的控件是原子化的,不可再分割的。

比如button控件,在unity3d里是由uisprite(scripts),uibutton(scripts),uibutton scale(scripts)等等脚本组合而来的。

理论上讲所有的常用控件都能由Empty通过Add Component组合得来。

 

通常由Empty创建一个Button步骤如下:

1.Create Empty

创建一个Empty GameObject,可以看到Inspector里显示这个GameObject只有一个叫Transform的东西。

2.增加一个uisprite(scripts)

在Inspector里面找到Add Component,输入ngui,选择添加NGUI Sprite

出现一个UISprite脚本

选好预先准备好的图片。

3.依次添加button,button scale,box collider这几个Component

4.图片自动适应box collider

在UISprite组件里选中auto-adjust to match

点击运行,这样就有了一个鼠标滑过会放大,鼠标点击会放大的简单button。

posted @ 2016-03-17 16:49  姚二二姚  阅读(399)  评论(0编辑  收藏  举报