lua cbi模块能够添加事件吗

lua cbi模块能够添加事件吗,第1张

一般来说 这样写比较好 B.lua local m = {} m.fun = function(){...} m.a = ... m.b = ... return m ------- A.lua m = require"B" 然后在A里就可以使用 m.a m.b m.fun()这样来访问模块里的东西

您好,这样的:

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 System.Collections

public class SpriteClickTest : MonoBehaviour {

private UISpriteAnimation spriteAnimation

void Start()

{

spriteAnimation = GetComponent<UISpriteAnimation>()

}

void OnClick()

{

if (spriteAnimation.isPlaying) {

// 暂停动画

spriteAnimation.Stop()

} else {

// 动画重新播放

spriteAnimation.Reset()

}

}

}

在Inspector窗口

点击运行游戏,刚才设置在精灵的脚本,就会相应OnClick事件了。


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

原文地址:https://54852.com/bake/11731774.html

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

发表评论

登录后才能评论

评论列表(0条)

    保存