Unity2017.1官方UGUI文档翻译——Interaction Components

Interaction Components

交互组件

This section covers components in the UI system that handles interaction, such as mouse or touch events and interaction using a keyboard or controller.

The interaction components are not visible on their own, and must be combined with one or more visual elements in order to work correctly.

这一节包括了UI系统中处理交互的组件,比如鼠标、触摸事件,还有使用键盘或控制器的交互

交互组件自己是不可见得,必须和一个或多个可见的组件结合才能正常工作

Common Functionality

通用功能

Most of the interaction components have some things in common. They are selectables, which means they have shared built-in functionality for visualising transitions between states (normal, highlighted, pressed, disabled), and for navigation to other selectables using keyboard or controller. This shared functionality is described on the Selectable page.

The interaction components have at least one UnityEvent that is invoked when user interacts with the component in specific way. The UI system catches and logs any exceptions that propagate out of code attached to UnityEvent.

大部分的交互组件有一些通用的部分。他们是可以被选择的,也就是说他们共享了内置的功能来实现可视状态的转换(普通、高亮、按下、不可用),还实现了通过键盘或控制器导航到其他的selectble组件。这些共享的功能在Selectable中有详细说明。(Selectable在源码中是很多可交互组件的基类,毕竟很多基础功能是通用的)

当用户用特定的方法和可交互组件交互的时候,至少有一个UnityEvent会被调用。UI系统会捕获并且记录所有从附加到UnityEvent的代码中传出的异常

Button

按钮

A Button has an OnClick UnityEvent to define what it will do when clicked.

按钮有一个OnClick事件来定义它被点击后会发生什么

See the Button page for details on using the Button component.

在Button页面查看使用Button组件的详细方法

Toggle

切换键

A Toggle has an Is On checkbox that determines whether the Toggle is currently on or off. This value is flipped when the user clicks the Toggle, and a visual checkmark can be turned on or off accordingly. It also has an OnValueCHanged UnityEvent to define what it will do when the value is changed.

切换键有一个复选框决定了这个选择键是否打开。在用户按下这个Toggle的时候,这个值会反过来,然后一个可视化的选择标记也会跟着变化。它还有一个OnValueChanged事件来定义当复选框的值变化时做什么

See the Toggle page for details on using the Toggle component.

在Toggle页面查看使用Toggle组件的详细方法

Toggle Group

切换按键组

A Toggle Group can be used to group a set of Toggles that are mutually exclusive. Toggles that belong to the same group are constrained so that only one of them can be selected at a time - selecting one of them automatically deselects all the others.

Toggle Group可以用来把一组Toggle分为一组,他们之间是互斥的。属于同一组的Toggle被限制了,在同一时间只有一个可以被选中-选中其中一个会自动关闭其它的

See the Toggle Group page for details on using the Toggle Group component.

在Toggle Group页面查看使用Toggle Group组件的详细方法

Slider

滑块

A Slider has a decimal number Value that the user can drag between a minimum and maximum value. It can be either horizontal or vertical. It also has a OnValueChanged UnityEvent to define what it will do when the value is changed.

滑块有意个小数值,用户可以在最小值和最大值之间拖拽。它可以是水平的也可以是垂直的。它还有一个OnValueChanged事件来定义这个值改变之后要做什么

See the Slider page for details on using the Slider component.

在Slider页面查看使用Slider组件的详细方法

Scrollbar

滑动条

A Scrollbar has a decimal number Value between 0 and 1. When the user drags the scrollbar, the value changes accordingly.

Scrollbars are often used together with a Scroll Rect and a Mask to create a scroll view. The Scrollbar has a Size value between 0 and 1 that determines how big the handle is as a fraction of the entire scrollbar length. This is often controlled from another component to indicate how big a proportion of the content in a scroll view is visible. The Scroll Rect component can automatically do this.

The Scrollbar can be either horizontal or vertical. It also has a OnValueChanged UnityEvent to define what it will do when the value is changed.

滑动条有一个在0-1之间的小数值。当用户拖拽ScrollBar的时候,这个值相应地改变

Scrollbars 经常和ScrollRect和Mask一起创建一个Scroll View。scroll bar有一个尺寸值在0和1之间,决定了把手占整个scrollbar长度的分数值。这一般由其他组件控制来表明在ScrollView中可见的内容占总内容的百分比。Scroll Rect组件可以自动设置它。

See the Scrollbar page for details on using the Scrollbar component.

在Slider页面查看使用Slider组件的详细方法

Dropdown

下拉菜单

A Dropdown has a list of options to choose from. A text string and optionally an image can be specified for each option, and can be set either in the Inspector or dynamically from code. It has a OnValueChanged UnityEvent to define what it will do when the currently chosen option is changed.

Dropdown 有一列选项可以选择。每个选项可以指定文字和图片(可选),这些可以在inspector中设置,也可以动态地在代码里设置。它还有一个Onvaluechange的事件来定义当选项改变时做什么

See the Dropdown page for details on using the Dropdown component.

在DropDown页面查看使用DropDown组件的详细方法

Input Field

输入栏

An Input Field is used to make the text of a Text Element editable by the user. It has a UnityEvent to define what it will do when the text content is changed, and an another to define what it will do when the user has finished editing it.

Input Filed 用来让文字元素的文字可以被用户编辑。它定义了文字内容改变的事件和文字编辑结束两个事件,来定义这两种情况下分别做什么。

See the Input Field page for details on using the Input Field component.

在Input Filed页面查看使用Input Files组件的详细方法

Scroll Rect (Scroll View)

滚动的矩形(滚动视图)

A Scroll Rect can be used when content that takes up a lot of space needs to be displayed in a small area. The Scroll Rect provides functionality to scroll over this content.

Usually a Scroll Rect is combined with a Mask in order to create a scroll view, where only the scrollable content inside the Scroll Rect is visible. It can also additionally be combined with one or two Scrollbars that can be dragged to scroll horizontally or vertically.

Scroll Rect用于内容占用很大地地方但是要现实在一个很小的区域。Scroll Rect提供了滚动内容的功能

一般情况下,Scroll Rect和Mask结合创建一个srcoll view,只有在Srcoll Rect 内的内容是可见的。通过结合1个或2个Scroll Bar它还被拖拽着滚动,它还可以被拖拽着水平或垂直滚动

See the Scroll Rect page for details on using the Scroll Rect component.

在Scroll Rect页面查看使用Scroll Rect组件的详细方法

时间: 2024-10-05 04:17:33

Unity2017.1官方UGUI文档翻译——Interaction Components的相关文章

Unity2017.1官方UGUI文档翻译——Canvas

Canvas 画布 The Canvas is the area that all UI elements should be inside. The Canvas is a Game Object with a Canvas component on it, and all UI elements must be children of such a Canvas. Creating a new UI element, such as an Image using the menu GameO

Unity2017.1官方UGUI文档翻译——Animation Integration

Animation Integration 动画集成 Animation allows for each transition between control states to be fully animated using Unity’s animation system. This is the most powerful of the transition modes due the the number of properties that can be animated simult

Unity2017.1官方UGUI文档翻译——Rich Text

Rich Text 富文本 The text for UI elements and text meshes can incorporate multiple font styles and sizes. Rich text is supported both for the UI System and the legacy GUI system. The Text, GUIStyle, GUIText and TextMesh classes have a Rich Text setting

Unity2017.1官方UGUI文档翻译——Canvas Scaler

Canvas Scaler 画布缩放器 The Canvas Scaler component is used for controlling the overall scale and pixel density of UI elements in the Canvas. This scaling affects everything under the Canvas, including font sizes and image borders. “画布缩放器”组件用于控制画布中UI元素的整

Unity2017.1官方UGUI文档翻译——Text

Text 文本 The Text control displays a non-interactive piece of text to the user. This can be used to provide captions or labels for other GUI controls or to display instructions or other text. 文本控件向用户显示一个非交互式的文本片段. 它可以作为其他GUI控件提供标题或标签,或作为说明文本,或者其他用途. P

Unity2017.1官方UGUI文档翻译——Raw Image

Raw Image 原生图片 The Raw Image control displays a non-interactive image to the user. This can be used for decoration, icons, etc, and the image can also be changed from a script to reflect changes in other controls. The control is similar to the Image 

Unity2017.1官方UGUI文档翻译——Mask

Mask 遮罩 A Mask is not a visible UI control but rather a way to modify the appearance of a control’s child elements. The mask restricts (ie, “masks”) the child elements to the shape of the parent. So, if the child is larger than the parent then only t

Unity2017.1官方UGUI文档翻译——RectMask2D

RectMask2D 矩形2D遮罩 A RectMask2D is a masking control similar to the Mask control. The mask restricts the child elements to the rectangle of the parent element. Unlike the standard Mask control it has some limitations, but it also has a number of perfo

Unity2017.1官方UGUI文档翻译——Position as UV1

Position as UV1 This adds a simple Position as UV1 effect to text and image graphics. 把Canvas空间下的顶点坐标设置到UV1中,用于在Text和Image这样的图形组件中实现一些特效(特效要自定义shader实现) Properties 属性 原文地址:https://www.cnblogs.com/SolarWings/p/8182972.html