Unity2017.1 official Ugui Document translation--dropdown

Source: Internet
Author: User
Tags canvas rectangle

Dropdown

Drop-down menu

The Dropdown can used to let the user choose a single option from a list of options.

Dropdown allows the user to select an option from a list of options.

The control shows the currently chosen option. Once clicked, it opens up the list of options so a new option can be chosen. Upon choosing a new option, the list of closed again, and the control shows the new selected option. The list is also closed if the user clicks on the control itself, or anywhere else inside the Canvas.

This control displays the currently selected option. Whenever clicked, it expands the list of options so that you can select a new option. When you select a new option, the list is collected, and then the space is displayed as a new selected option. If the user clicks on the control itself (not the list) or somewhere else on the canvas, the expanded list will be collected.

A Dropdown.

A drop-down menu

A Dropdown with its list of options open.

A drop-down menu that expands the list of options

Properties

Property

Property
: Function:
Interactable Would this component would accept input? See interactable.
Transition

Properties that determine the control responds visually to user actions.

See Transition Options.

Navigation Properties that determine the sequence of controls. See Navigation Options.
Template The Rect Transform of the template for the dropdown list. See instructions below.
Caption Text The text component to the text of the currently selected option. (Optional)
Caption Image The image component to hold the image of the currently selected option. (Optional)
Item Text The text component to the text of the item. (Optional)
Item Image The image component to hold the image of the item. (Optional)
Value The index of the currently selected option. 0 is the first option, 1 is the second, and so on.
Options The list of possible options. A text string and an image can is specified for each option.
Properties function
Interactable Will this component accept input? See interactable.
Transition

A property that determines how a control can visually respond to user actions.

See transition Options.

Navigation Determines the response of the control to different directions when navigating. See Navigation Options.
Template

The Recttransform of the drop-down list template. See the instructions below.

Caption Text

Display text for selected options (optional)

Caption Image Display picture of selected options (optional)
Item Text

The text in the drop-down box option template (optional) will cause each option in the list of options not to modify the text in the template

Item Image The picture in the drop-down box option template (optional) will cause each option in the list of options not to modify the picture in the template
Value

The subscript for the currently selected option. 0 represents the first option, 1 for the second, and so on

Options

A list of optional options. Each option can specify text and image

Events

Event

Property
: Function:
On Value Changed A unityevent that was invoked when a user had clicked one of the options in the dropdown list.
Properties function
On Value Changed When the user clicks an option in the drop-down list, a unityevent is called
Details

With

The list of options is specified in the Inspector or can be assigned from code. For each option a text string can being specified, and optionally an image as well, if the Dropdown are setup to support it.

The list of options can be specified in inspector or in code. If dropdown is supported when initializing (item text or item Image is set), for each option, you can specify text or specify an image.

The button has a single event called on Value Changed This responds when the user completes a click on one of the Options in the list. It supports sending an integer number value, the index of the selected option. 0 is the first option, 1 is the second, and so on.

This button has an event called on Value Changed, which is responded to when the user taps an item in the list of options. It supports sending an integer value indicating the subscript of the currently selected option. 0 represents the first, 1 for the second, and so on.

The template system

Template system

The Dropdown control is designed to has a child gameobject which serves as a template for the Dropdown list which is shown When clicking the dropdown control. The template gameobject is inactive by default and can be made active while editing the template to better see what ' s Goi Ng on. A reference to the template object must is specified in the template property of the Dropdown component.

The dropdown control is designed with a sub-gameobject as a template for the drop-down list. This template Gameobject by default is inactive, but you can edit it by first active it to see a clear change. You must specify a reference to this template in the dropdown control's template property.

The template must has a single item in it with a Toggle component on. When the actual dropdown list was created upon clicking the dropdown control, this item was duplicated multiple times, with One copy used for each option in the list. The parent of the item is automatically resized so it can fit all the items inside.

The template must have a separate entry, and this entry (item) must have an open-state toggle component. When you click on the dropdown control and actually create a drop-down list, the item is copied multiple copies, and each option in the list of options corresponds to one copy. The parent of the entry (item) automatically adjusts the size so that it can load all the entries (item).

A Simple dropdown setup where the item is A immediate child of the template.

A simple drop-down menu. An entry (item) is a template for a direct child.

A more advanced dropdown setup, includes a scrollview that enables scrolling when there is many options in the list.

More advanced drop-down list settings, including ScrollView, can support scrolling when there are many options.

The template can be setup in many different ways. The setup used by the Gameobject > UI > Dropdown menu item includes a scroll view, such that if there is too many O Ptions to show at once, a scrollbar would appear and the user can scroll through the options. This was however not a mandatory part of the template setup.

The template can be set in a variety of ways, with the Gameobject > UI > Dropdown menu using settings that include scroll View, so if you want to show too many options here at once, a scroll slider will appear and the user can swipe the option. However, this is not a mandatory part of the template setup.

(See the ScrollRect page for more information on setup of Scroll views.)

For more information on setting scroll views, see the Scrollrect page.

Setup of text and image support

Settings supported by text and image

The dropdown supports one text content and one image content for each option. Both text and image is optional. They can only be used if the Dropdown are setup to support it.

The drop-down menu supports one text content per option and one image content. Both the text and the image are optional. You can use them only if you set the drop-down menu to support them.

The dropdown supports text for each option when the Caption text and Item text properties is both setup. These is setup by default when using the Gameobject > UI > Dropdown menu item.

When both the Caption text and the item text properties are set, the drop-down menu supports the text for each option. These are set by default when you use the Gameobject> ui> dropdown menu item.

    • The Caption text is the text component to the text for the currently selected option. It's typically a child to the Dropdown gameobject.
    • Caption text is used to display the text description of the currently selected option. It is generally a child of the dropdown gameobject
    • The Item text is the text component to the text for each option. It's typically a child to the Item gameobject.
    • Item text is a textual description of the template used to display each option. It is usually a child node of item gameobject (this piece of text is very round, it is recommended to create a dropdown to see)

The dropdown supports an image for each option when the Caption image and Item image properties is both setup. These is not setup by default.

When both the caption image and the item image properties are set, the drop-down menu supports an image for each option. These two properties are not set by default.

    • The Caption image is the image component to hold the image for the currently selected option. It's typically a child to the Dropdown gameobject.
    • Caption image is the picture that is used to display the currently selected option. It is generally a child of the dropdown gameobject
    • The Item image is the image component to hold the image for each option. It's typically a child to the Item gameobject.
    • Item image is a picture of the template used to display each option. It is generally the child node of item Gameobject

The actual text and images used for the dropdowns is specified in the Options property of the Dropdown component, or can is set from code.

The actual text and pictures in the drop-down list are specified in the Options property of the dropdown component, or can be specified in the code.

Placement of the dropdown list

Place drop-down list

The placement of the dropdown list in relation to the dropdown control are determined by the anchoring and pivot of the REC T Transform of the Template.

The drop-down list placement and the dropdown control's association depend on the rect transform anchor Point and pivot point of the template (templated)

By default, the list would appear below the control. This was achieved by anchoring the template to the bottom of the control. The pivot of the template also needs to being at the top, so, as the template was exapanded to accommodate a variable numb Er of option items, it only expands downwards.

By default, the list appears below the dropdown control. This is done by setting the template's anchor point at the bottom of the dropdown control. The pivot point of the template also needs to be at the top, so when it expands to accommodate a variable number of options, it only scales down.

The Dropdown control has simple logic to prevent that the Dropdown is displayed outside the bounds of the Canvas, since th Is would make it impossible to select certain options. If the dropdown at it default position is not fully within the Canvas rectangle, it position in relation to the control is reversed. For example, a list of that was shown below the control by default would be shown above it instead.

The Dropdown control has a simple logic to prevent the drop-down list from appearing outside the bounds of the canvas, causing some options to be selected. If the dropdown is not fully visible in the canvas's rectangular area in the default location, the relative position of the list and controls may be reversed. For example, a list that appears below the dropdown control appears above the dropdown control

This logic was quite simple and have certain limitations. The dropdown template needs to be no larger than half the Canvas size minus the size of the dropdown control, otherwise th Ere may isn't the be-for-the-list at either position if the dropdown control was placed in the middle of the Canvas.

This logic is simple and has some limitations. The size of the template cannot be larger than half the size of the canvas minus the drop-down control, or if the drop-down control is placed in the middle of the canvas, there may be no space in either location.

Unity2017.1 official Ugui Document translation--dropdown

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.