# 学会 UGUI 之 Toggle & Toggle Group

Toggle #

The Toggle control is a checkbox that allows the user to switch an option on or off.

属性:

Interactable → Will this component will accept input?
将此组件将接受输入吗?

Transition → Properties that determine the way the control responds visually to user actions.
属性确定控件针对对用户操作方式的的响应方式。

Navigation → Properties that determine the sequence of controls.
属性确定控件的顺序。

Toggle Transition → The way the toggle reacts graphically when its value is changed. The options are None (ie, the checkmark simply appears or disappears) and Fade (ie, the checkmark fades in or out).
当它的值被更改,切换方式以图形方式反应。选项是 None (ie,复选标记只是出现或消失)和淡入淡出(即复选标记消失或缩小)。

Graphic → The image used for the checkmark.
用于复选标记的图像。

Group → The Toggle Group (if any) that this Toggle belongs to.
此开关属于的开关切换组(如果有)。

事件:

On Value Changed → A UnityEvent that is invoked when the Toggle is clicked. The event can send the current state as a bool type dynamic argument.
当这个 Toggle 被点击的时候会触发一个事件(其值更改就会处理开关切换的响应),这个事件发送当前状态,此状态以 bool 类型的动态参数传递。

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.

开关切换组是不可见的 UI 控件,但是可以在要修改其内一组单选按钮的行为。同一组的 Toggle 属于同一个约束的 Group,其中同一时刻只有一个 Toggle 能被切换状态,点击触发选择其中之一的同时时将自动取消其他 Toggle 的状态。