unity NGUI Tutorial event system

NGUI features a powerful event system, and it's not limited to just UI.  Any game object that has a collider is capable of receiving events.  All that's needed is an NGUI Event System script (UICamera) attached to the camera that draws the object.

All UIs have it attached by default, but if you want your 3D game objects to receive OnClick, OnPress and other events, you will need to attach the event system script to your Main Camera, and then to actually have a script attached to your game object that implements one or more of these functions:

void OnHover (bool isOver);
voidOnPress (bool isPressed);
void OnSelect (bool isSelected);
void OnClick ();
void OnDoubleClick ();

There are more events -- drag, scroll, key, and tooltip -- but if you want to know more, right-click the UICamera script in Inspector and choose Help.

Or just use the NGUI menu up top and choose Help there.



同时有一个强大的事件系统,它不是局限于UI。任何游戏对象,对撞机能够接收事件。所有需要的是一个同时事件系统脚本(UICamera)连接到相机吸引的对象。


ui都附加在默认情况下,但如果你想让你的3d游戏对象接收OnClick,OnPress和其他事件,您将需要将事件系统脚本附加到你的主要相机,然后有一个脚本附加到你的游戏对象实现一个或多个这样的功能:


void OnHover (bool isOver);
voidOnPress (bool isPressed);
void OnSelect (bool isSelected);
void OnClick ();
void OnDoubleClick ();


有更多的事件——拖,滚动,钥匙,和工具提示——但是如果你想知道更多,右键单击UICamera脚本检查并选择有所帮助。


或者只是使用菜单上面选择和帮助。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值