unity NGUI tutorial more events

本文介绍NGUI提供的多种脚本,模仿常见的用户界面行为,如按钮、开关、滑块等,并阐述如何通过这些脚本轻松创建自定义事件响应。此外还介绍了如何不编写脚本而使用UIEventTrigger来触发远程函数。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

NGUI provides a variety of scripts imitating common behaviours such as Button, Toggle, Slider, Scroll bar, etc. Each one provides additional events to go with it.  For example, the Button class can trigger one or more functions when clicked, and the Slider can notify a remote function when its value changes.  This makes it very easy to create custom scripts that tie into these events.

If you don't want to write scripts, use the UIEventTrigger script to trigger remote functions instead.

You can also chain events together.  For example if you hit Play and press the Click Me button, it will cause the tween on the first square to start playing.  When it finishes, it will trigger the tween on the next square, and that one will trigger the third, all the way to the last one which will trigger the first, creating a looping effect.

The slider is set to notify a script that controls the speed at which the tweens animate. Give it a try, hit Play and click the button!


同时提供了各种脚本模仿常见行为如按钮、开关、滑动、滚动条等。每一个提供了额外的事件。例如,按钮类可以触发一个或多个功能点击时,滑块可以通知远程函数时它的价值变化。这使得它很容易创建自定义脚本连接到这些事件。


如果你不想写脚本,使用UIEventTrigger脚本触发远程功能。


你也可以把事件串在一起。例如如果你点击播放,按点击我按钮,它会导致渐变第一个正方形开始播放。当它完成时,它将触发下一个正方形上的渐变,一直到最后一个将触发第一个,创建一个循环的效果。


滑块设置为通知的脚本控制的速度补间动画。尝试一下,点击播放,然后单击按钮!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值