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.
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脚本检查并选择有所帮助。
或者只是使用菜单上面选择和帮助。