Unity2017.1官方UGUI文档翻译——Toggle Group

ToggleGroup用于确保一组Toggle中仅有一个处于激活状态。该组件不是UI元素,而是通过约束多个Toggle实现互斥选择的功能,适用于玩家角色类型、速度设置等场景。用户可以通过设置AllowSwitchOff属性控制是否允许没有Toggle处于选中状态。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Toggle Group

 复选框组

A Toggle Group is not a visible UI control but rather a way to modify the behavior of a set of Toggles. Toggles that belong to the same group are constrained so that only one of them can switched on at a time - pressing one of them to switch it on automatically switches the others off.

Toggle Group不是一个可见的UI空间而是修改一组Toggles的行为的方法。属于同一个Toggle Group的Toggle在同一时间只有一个可以处于打开状态 - 点击一个Toggle并打开它会自动关闭其它已经打开的Toggle

A Toggle Group

A Toggle Group

一个复选框组

Properties

属性

Property:Function:
Allow Switch Off

Is it allowed that no toggle is switched on? If this setting is enabled,

pressing the toggle that is currently switched on will switch it off,

so that no toggle is switched on. If this setting is disabled,

pressing the toggle that is currently switched on will not change its state.

属性功能
Allow Switch Off

勾选这个选项会允许所有Toggle都处于关闭的状态。

如果这个设置是开启的,按下当前打开的Toggle会关闭掉它,

这时候是没有Toggle处于选中状态的。如果没有勾选,

那么点击已经打开的Toggle不会改变它的状态

 

Description

描述

The Toggle Group is setup by dragging the Toggle Group object to the Group property of each of the Toggles in the group.

通过将Toggle Group对象拖动到每个Toggle的Group属性来设置Toggle Group

Toggle Groups are useful anywhere the user must make a choice from a mutually exclusive set of options. Common examples include selecting player character types, speed settings (slow, medium, fast, etc), preset colors and days of the week. You can have more than one Toggle Group object in the scene at a time, so you can create several separate groups if necessary.

Toggle Group在用户必须从一组互斥的选项中做出选择的任何地方都是有用的。 常见的例子包括选择玩家角色类型,速度设置(慢,中,快等),预设颜色和星期几。 同一时间可以在场景中拥有多个Toggle Group,因此您可以根据需要创建多个单独的组。

Unlike other UI elements, an object with a Toggle Group component does not need to be a child of a Canvas object, although the Toggles themselves still do.

不像其它UI元素,具有Toggle Group组件的对象不需要是Canvas对象的孩子节点,尽管Toggle本身是要在Canvas下的

Note that the Toggle Group will not enforce its constraint right away if multiple toggles in the group are switched on when the scene is loaded or when the group is instantiated. Only when a new toggle is swicthed on are the others switched off. This means it’s up to you to ensure that only one toggle is switched on from the beginning.

请注意,如果在加载场景或实例化组时Toggle Group中的多个Toggle是打开的状态,Toggle Group将不会立即强制执行其约束。 只有当新的Toggle切换时,Toggle才会被关闭。 这意味着你要确定一开始只有一个Toggle是打开的状态

转载于:https://www.cnblogs.com/SolarWings/p/8185559.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值