unity NGUI tutorial more events

来源:互联网 发布:淘宝做代销能赚钱吗 编辑:程序博客网 时间:2024/06/15 12:55
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脚本触发远程功能。


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


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

0 0
原创粉丝点击