lua如何获取ngui单击事件

lua如何获取ngui单击事件,第1张

您好,这样的:
NGUI中,Button本身就带有OnClick事件,但是Sprite,Label等( 也绑有Widget的)并没有触发事件,其实NGUI的事件触发都必须添加Box Collider,并勾选Is Trigger,在Inspector窗口设置Box大小尺寸,可以在Widget的Collider勾选auto-adjust to match。还有一个比较重要的参数需要设置正确,即是UI Root下Camera参数,在Inspector窗口中,要确定UICamera中的Event Type选择3D UI,Event Mask选择Everything。
然后添加C# Script脚本,
using UnityEngine;
using SystemCollections;
public class SpriteClickTest : MonoBehaviour {
private UISpriteAnimation spriteAnimation;
void Start()
{
spriteAnimation = GetComponent<UISpriteAnimation>();
}
void OnClick()
{
if (spriteAnimationisPlaying) {
// 暂停动画
spriteAnimationStop();
} else {
// 动画重新播放
spriteAnimationReset();
}
}
}
在Inspector窗口
点击运行游戏,刚才设置在精灵的脚本,就会相应OnClick事件了。

以上就是关于lua如何获取ngui单击事件全部的内容,包括:lua如何获取ngui单击事件、、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/9282384.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-26
下一篇 2023-04-26

发表评论

登录后才能评论

评论列表(0条)

保存