码迷,mamicode.com
首页 > 其他好文 > 详细

NGUI Tutorial 3

时间:2014-07-20 22:02:43      阅读:325      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   使用   width   

一、 Create a Button

   一、(Menu)NGUI -> Create -> Sprite

  bubuko.com,布布扣

       二、attach box colider to the Sprite , then attach UIButton Script

      bubuko.com,布布扣

       三、Create - >Lable as Sprite‘s Child, Set it‘s Ahchors to it‘s Parent

 (注意:不要给Lable添加box colider 这样Sprite按钮就接受不到事件了,因为Lable 的Depth 大于 Sprite)

       bubuko.com,布布扣       

      四、Sprite attach UIButton Script Again ,set target as Lable

      五、Hover the button ,you will seen Sprite and Lable all highlight.

        bubuko.com,布布扣

二、Event Trigger -> Use Button Change

      一、create a spirte ,which will be changed by button

      bubuko.com,布布扣

  二、attach Tween Height and Tween Width ,set valuse like that

  (注意,set two scripts active  false ,这样就不会一开始就变换形状了)

     bubuko.com,布布扣

     三、attach UIEvent Trigger to button,set event to change sprite,like that

     bubuko.com,布布扣

   四、now  show the result

    Hover:  Change Size

   bubuko.com,布布扣

    Leave : Noraml Size

    bubuko.com,布布扣

 

三、UIKeyBinding 

  绑定一个快捷键去激活一个按钮,输入框或选择一个对象。

  一、Attach UIKeyBinding Script to button

  bubuko.com,布布扣

  二、Attach Test Scrpit to Sprite

  bubuko.com,布布扣

  三、Set OnClick Event Notify Object reference to Sprite

     bubuko.com,布布扣

      四、Now , you can enter 1,2,3 to change sprite color.

      bubuko.com,布布扣

      OfSourse you can alse 使用键盘来控制 UIInput

      liket that

  bubuko.com,布布扣

 

  

  你也可以使用UIKeyNavigation ——附加这个脚步到你的控制上去允许使用键盘或控制器来定位UI(3.5.5新增)

NGUI Tutorial 3,布布扣,bubuko.com

NGUI Tutorial 3

标签:style   blog   http   color   使用   width   

原文地址:http://www.cnblogs.com/chongxin/p/3856563.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!