xl95209064 发表于 2021-12-12 20:46:22

自定义控件组怎么获取其中的数据

我用自定义控件组做了一排按钮,怎么用代码判断当前点击的是哪个按钮?和怎么获取当前按下按钮的数据?
http://bbs.cedong.com.cn/forum.php?mod=image&aid=2954&size=300x300&key=41442b5c31557195&nocache=yes&type=fixnone

Jwx 发表于 2021-12-16 15:08:08

You can see this treat for reference (control group part) http://bbs.cedong.com.cn/forum.p ... =764&extra=page%3D2

And you can get data of each button and store it in a variable with a scripts to use it later.

Ex. your traverse object in the UI control group could be an a data array like : items = ["coins","potions","gold","medals"]

In Controls, you can name your button with: obj, to display names in each button, then you can add an action when click it whit a script like: RV.GameData.value = obj;to store the value in a string variable.

---------------------------------------
你可以看看这个供参考(对照组部分) http://bbs.cedong.com.cn/forum.p ... =764&extra=page%3D2

您可以获取每个按钮的数据并将其存储在带有脚本的变量中以供以后使用。

前任。 UI 控制组中的遍历对象可能是一个数据数组,例如:items = ["coins","potions","gold","medals"]

在控件中,您可以将您的按钮命名为:obj,以在每个按钮中显示名称,然后您可以在单击它时添加一个动作,例如:RV.GameData.value = obj; 将值存储在字符串变量中。
页: [1]
查看完整版本: 自定义控件组怎么获取其中的数据