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

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