当前位置:网站首页>Ugui learning notes (V) togglegroup makes multiple choice radio boxes
Ugui learning notes (V) togglegroup makes multiple choice radio boxes
2022-07-28 17:05:00 【More than a curtain a dream】
UGUI There is one Toggle Components Used to make a checkable option , The component panel is shown in the figure below
among Interactable Option is used to select whether it is operable , If it is not checked, it is inoperable ,isOn It is used to judge the current Toggle Check status of ,OnValueChanged It is the present. Toggle When the value is changed, it will be called , You can add monitoring in the code , You can also drag the object directly to the panel to select a method to listen . Let's focus on this Group attribute .
Mount one on other objects ToggleGroup Options , In other Toggle Panel Group Admiral, this ToggleGroup Drag objects in , Those Toggle It becomes a group , In a group Toggle There can only be one Toggle Checked .ToggleGroup The panel is shown in the figure below :
The panel is very simple, there is only one AllowSwitchOff Properties of , Used to select all Toggle Can it be unchecked at the same time . But it has some methods that need to be explained .
ToggleGroup Inherited from UIBehaviour, Multiple Toggle Divide into one group and keep at most one Toggle Status as On. It has one m_Toggles Member variables of , This is a Toggle Type of List, Used to save the registration in this ToggleGroup All of the Toggle. As mentioned above ,Toggle stay OnEnable Register to group,OnDisable Time to move out group, In addition, by group Attribute assignment can also make Toggle Register to the designated ToggleGroup( Generally, the editor helps us set ).
The code for registration and removal is simple , Will be toggle Join in m_Toggles Or from m_Toggles Delete .NotifyToggleOn This method will be in addition to the input Toggle All the other Toggle All closed (isOn = false). We can also call ToggleGroup Some of the ways , for example AnyTogglesOn To determine if there is Toggle Turn on (Toggle Of set Method also calls this method , That is, there is no Toggle Open and group Not all Toggle When it's closed , Force to on ),ActiveToggles Get open Toggle,SetAllTogglesOff Close all Toggle.
ActiveToggles Get open Toggle, This method returns zero IEnumerable<Toggle> One of this type Toggle Set , Want to put Toggle Type read , You have to pass the following code
IEnumerable<Toggle> answersGroup = ToggleGroup.ActiveToggles();
foreach (Toggle t in answersGroup)
{// Traverse this storage Toggle Button group for IEnumerable, This is C# An enumerated collection of , General direct use foreach Traverse
if (t.isOn)// Traverse to a selected Toggle
{
switch (t.name)// According to this Toggle Of name, We give string sex Give different values
{
case "Toggle0":
sex = " male ";
break;
case "Toggle1":
sex = " Woman ";
break;
}
break;// There is no need to traverse , It can be foreseen later , Are not selected Toggle.
}
}边栏推荐
- Signal and slot mechanism of QT learning
- Semtech launched Lora edge, a geolocation solution for the Internet of things, and the first chip lr1110 is now on the market
- Re13: read the paper gender and racial stereotype detection in legal opinion word embeddings
- Time complexity
- QT designer for QT learning
- [deep learning]: day 5 of pytorch introduction to project practice: realize softmax regression from 0 to 1 (including source code)
- Re10: are we really making much progress? Revisiting, benchmarking, and refining heterogeneous gr
- 在AD中添加差分对及连线
- go语言慢速入门——流程控制语句
- Call DLL file without source code
猜你喜欢

Re10: are we really making much progress? Revisiting, benchmarking, and refining heterogeneous gr

Re10:读论文 Are we really making much progress? Revisiting, benchmarking, and refining heterogeneous gr

【深度学习】:《PyTorch入门到项目实战》第五天:从0到1实现Softmax回归(含源码)

Comprehensively design an oppe homepage -- page service part

Learn to use MySQL explain to execute the plan, and SQL performance tuning is no longer difficult

小程序:scroll-view默认滑倒最下面

Re11: read EPM legal judgment prediction via event extraction with constraints

阿里大哥教你如何正确认识关于标准IO缓冲区的问题

Do you really understand CMS garbage collector?

Technology sharing | how to recover the erroneously deleted table and the data in the table?
随机推荐
如何使用Fail2Ban保护WordPress登录页面
College students participated in six Star Education PHP training and found jobs with salaries far higher than those of their peers
MD5加密验证
Exercise note 5 (square of ordered array)
做题笔记4(第一个错误的版本,搜索插入位置)
Reduce cycle complexity
Alibaba cloud - Wulin headlines - site building expert competition
Deep understanding of deepsea and salt deployment tools – storage6
Signal and slot mechanism of QT learning
How should I understand craft
Record the processing process of CEPH two RBDS that cannot be deleted
2019年全球移动通信基站市场:爱立信、华为、诺基亚分列前三
Given positive integers n and m, both between 1 and 10 ^ 9, n < = m, find out how many numbers have even digits between them (including N and m)
[deep learning]: day 1 of pytorch introduction to project practice: data operation and automatic derivation
Re10:读论文 Are we really making much progress? Revisiting, benchmarking, and refining heterogeneous gr
【JS】1394- ES2022 的 8 个实用的新功能
PHP calculate coordinate distance
HTAP是有代价的
【深度学习】:《PyTorch入门到项目实战》第六天:多层感知机(含代码)
【深度学习】:《PyTorch入门到项目实战》第五天:从0到1实现Softmax回归(含源码)