UGUI-Canvas

 
Toggle中的四个状态同Button一样,核心部分是可以勾选白框部分,Is on表示其状态,可以通过Is on的true和false来触发需要的方法
我们可以通过创建一个空物体,然后在该空物体下,,创建几个Tongle子物体,然后在空物体上加上一个组件 ToggleGroup,可以实现
这个空物体下的几个Toggle只可以勾选一个的效果. 其中ToggleGroup中的 AllowSwitchOff勾选上表示允许一个都不勾选,否则必须
勾选且只能勾选一个.
 
 
附上Toggle的API
 

Description

A standard toggle that has an on / off state.

The toggle component is a Selectable that controls a child graphic which displays the on / off state. 

When a toggle event occurs a callback is sent to any registered listeners of onValueChanged.

Variables

graphicGraphic affected by the toggle.
groupGroup the toggle belongs to.
isOnIs the toggle on.
onValueChangedCallback executed when the value of the toggle is changed.
toggleTransitionTransition mode for the toggle.

Public Functions

OnPointerClickHandling for when the toggle is 'clicked'.
OnSubmitHandling for when the submit key is pressed.
RebuildHandling for when the canvas is rebuilt.

Inherited members

Static Variables

allSelectablesList of all the selectable objects currently active in the scene.

Variables

enabledEnabled Behaviours are Updated, disabled Behaviours are not.
isActiveAndEnabledHas the Behaviour had enabled called.
gameObjectThe game object this component is attached to. A component is always attached to a game object.
tagThe tag of this game object.
transformThe Transform attached to this GameObject (null if there is none attached).
useGUILayoutDisabling this lets you skip the GUI layout phase.
hideFlagsShould the object be hidden, saved with the scene or modifiable by the user?
nameThe name of the object.
animationTriggersThe AnimationTriggers for this selectable object.
animatorConvenience function to get the Animator component on the GameObject.
colorsThe ColorBlock for this selectable object.
imageConvenience function that converts the referenced Graphic to a Image, if possible.
interactableUI.Selectable.interactable.
navigationThe Navigation setting for this selectable object.
spriteStateThe SpriteState for this selectable object.
targetGraphicGraphic that will be transitioned upon.
transitionThe type of transition that will be applied to the targetGraphic when the state changes.

转载于:https://www.cnblogs.com/pursuer-lzc/p/4534501.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值