UGUI-Canvas

Toggle中的四个状态同Button一样,核心部分是可以勾选白框部分,Is on表示其状态,可以通过Is on的true和false来触发需要的方法

我们可以通过创建一个空物体,然后在该空物体下,,创建几个Tongle子物体,然后在空物体上加上一个组件 ToggleGroup,可以实现

这个空物体下的几个Toggle只可以勾选一个的效果. 其中ToggleGroup中的 AllowSwitchOff勾选上表示允许一个都不勾选,否则必须

勾选且只能勾选一个.

附上Toggle的API

Toggle

Namespace: UnityEngine.UI

/

Inherits from: UI.Selectable

Implements interfaces: ICanvasElementIDeselectHandlerIEventSystemHandler,

IEventSystemHandlerIMoveHandlerIPointerClickHandlerIPointerDownHandler,

IPointerEnterHandlerIPointerExitHandlerIPointerUpHandlerISelectHandlerISubmitHandler

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

graphic Graphic affected by the toggle.
group Group the toggle belongs to.
isOn Is the toggle on.
onValueChanged Callback executed when the value of the toggle is changed.
toggleTransition Transition mode for the toggle.

Public Functions

OnPointerClick Handling for when the toggle is ‘clicked‘.
OnSubmit Handling for when the submit key is pressed.
Rebuild Handling for when the canvas is rebuilt.

Inherited members

Static Variables

allSelectables List of all the selectable objects currently active in the scene.

Variables

enabled Enabled Behaviours are Updated, disabled Behaviours are not.
isActiveAndEnabled Has the Behaviour had enabled called.
gameObject The game object this component is attached to. A component is always attached to a game object.
tag The tag of this game object.
transform The Transform attached to this GameObject (null if there is none attached).
useGUILayout Disabling this lets you skip the GUI layout phase.
hideFlags Should the object be hidden, saved with the scene or modifiable by the user?
name The name of the object.
animationTriggers The AnimationTriggers for this selectable object.
animator Convenience function to get the Animator component on the GameObject.
colors The ColorBlock for this selectable object.
image Convenience function that converts the referenced Graphic to a Image, if possible.
interactable UI.Selectable.interactable.
navigation The Navigation setting for this selectable object.
spriteState The SpriteState for this selectable object.
targetGraphic Graphic that will be transitioned upon.
transition The type of transition that will be applied to the targetGraphic when the state changes.
时间: 2024-10-13 01:24:06

UGUI-Canvas的相关文章

UGUI Canvas 与 特效

UGUI Canvas SortingLayer决定了该Canvas下面的所有子物体的SortingLayer,一个Canvas下面的子物体按照上下顺序排序,越靠前的越容易被遮挡,当子物体拥有Canvas组件时,渲染队列将被重写,该物体的遮挡关系取决于当前物体的Canvas的orderInLyaer,所以UI应该优先按照Layer排序,然后同意Layer按照OrderInLayer进行排序,同一个OrderInLayer的Canvas下,按照上下顺序排序. 特效同样支持sortingOrder与

【转】(二)unity4.6Ugui中文教程文档-------概要-UGUI Canvas

原创至上,移步请戳:(二)unity4.6Ugui中文教程文档-------概要-UGUI Canvas UI系统允许您快速.直观地创建用户界面(Ui).这是Unity的新 UI 系统的主要功能介绍. 一.UI Overview概要 在这篇概述中,我们就去通过 UI系统的基础知识.我们将开始介绍Canvas(画布)并将所有 UI 元素都放在里面,和使用Rect Tool和Rect Transform进行UI元素排版.然后我们来看看视觉元素像Text和Image,和交互控件,如Button按钮和S

Unity UGUI - Canvas / Camera

1.Canvas: 1)Render Mode : Screen Space -Camera 2)Render Camera : UICamera(自己创建的相机) 3)Plane Distance : 0 2.Canvas Scaler: 1)Ui Scale Mode : Scale with screen size (宽度标准缩放) 2)Reference Resolutioin: 1920 * 1080   (屏幕分辨率) 3)Screen Match Mode: Expand (UGU

Unity UGUI Canvas 使用Slider制作角色血条

最近课程实训选修Unity,讲解的是Unity官方案例--SpaceShoot,培训无聊,便想着给游戏角色制作一下血条,以此增加游戏的可玩性. Unity版本:5.4.1 案例模版:太空射击 原文作者:茄阁云云 原文连接:http://www.cnblogs.com/vmoor2016/p/6044941.html 把一个大象装进冰箱里需要三步:①把冰箱门打开:②把大象塞冰箱里:③关上冰箱门. 那么制作一个角色的血条需要几部呢?在这里也划分为三步:①制作血条:②摆放血条:③操作血条. 下面就来给

(二)unity4.6学习Ugui中文文档-------概要-UGUI Canvas

大家好,我是孙广东.   转载请注明出处:http://write.blog.csdn.net/postedit/38922399 更全的内容请看我的游戏蛮牛地址:http://www.unitymanual.com/forum.php?mod=guide&view=my UI系统允许您快速.直观地创建用户界面(Ui).这是Unity的新 UI 系统的主要功能介绍. 一.UI Overview概要 在这篇概述中,我们就去通过 UI系统的基础知识.我们将开始介绍Canvas(画布)并将所有 U

[转](二)unity4.6Ugui中文教程文档-------概要-UGUI Canvas

大家好,我是孙广东.   转载请注明出处:http://write.blog.csdn.net/postedit/38922399 更全的内容请看我的游戏蛮牛地址:http://www.unitymanual.com/forum.php?mod=guide&view=my UI系统允许您快速.直观地创建用户界面(Ui).这是Unity的新 UI 系统的主要功能介绍. 一.UI Overview概要 在这篇概述中,我们就去通过 UI系统的基础知识.我们将开始介绍Canvas(画布)并将所有 UI 

Unity UGUI——Canvas绘制模式比较

三种绘制模式:Screen Space - Overlay.Screen Space - Camera和World Space

UGUI-1.Canvas

2015-06-22 1.UGUI Canvas 画布 The Canvas component represents the abstract space in which the UI is laid out and rendered. All UI elements must be children of a GameObject that has a Canvas component attached. When you create a UI element object from t

Unity Optimization UNITY优化关注列表

这里主要罗列Unity引擎进行开发的应用或游戏,可以进行优化的各个关注点.(此文会持续更新) C# GC alloc Update LateUpdate Serialize String ToString() += Getter API Object.name GetComponents Sprite.vectices Debug.Log Closure anonymous function Unity API ParticleSystem Start Stop Pause Clear Simu

UGUI初学习--------Canvas

今天仔细研究了一下UGUI觉得有必要写一篇文章来分享一下.废话不多说直接开码字..... 作者之前也学过NGUI.这里来说明一下,UGUI和NGUI的渲染结构略有不同,UGUI中将NGUI中的深度处理项取消了.UGUI的渲染是按照Hierarchy的UI游戏对象的排列顺序从上到下依次渲染的,重叠部分后渲染的会把先渲染的挡住.总结一句话:下在上前,子在父前.为了修改各个UI控件的绘制顺序,开发者可以采用以下两种方法:拖动Hierarchy视图里的各UI控件对象,改变它们在Canvas下的排列顺序: