Unity2017.1 official Ugui Document translation--mask

Source: Internet
Author: User

Mask Mask

A Mask is not a visible UI control but rather a-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-the child is larger than the parent and then only the part of the fits within the parent would be visible.

Mask is not a visual UI control, it is a way to change the display of a control's child elements. Mask restricts the elements of the handle to the shape of their parent element. Therefore, if the child is larger than the parent node, only the part within the parent node is visible.

section of a large Image masked by a Panel (Scrollbars is separate controls)

The portion of a large image that is masked by the panel (ScrollBars is a separate control)

Properties

Property

Property
: Function:
Show Graphic Should the graphic of the masking (parent) object is drawn with an alpha over the child object?
Properties function
Display image Whether the shape of the matte object should contain alpha drawn on the child object
Description

Describe

A common use of a Mask was to show a small section of a large Image, using say a Panel object (Menu:gameobject > Create UI > Panel) as a "frame". You can achieve this by firstly making the Image a child of the Panel object. You should position the Image so, the area of the should be visible are directly behind the Panel area.

A common use of mask is to display a small portion of a larger image, using a Panel object (menu:gameobject> Create ui> Panel) as the "frame." You can do this by first making the image a child of the Panel object. You should adjust the position of the picture so that the area that should be visible is right behind the panel area.

Panel area shown in red with child Image behind

The area of the panel is indicated in red, and the picture is behind it

Then, add a Mask component to the Panel. The areas of the child Image outside the panel would become invisible since they is masked by the shape of the panel.

Then, add a mask component to the panel. Sub-images are not visible in areas outside the panel because they are masked by the Panel's shape.

Masked areas shown faint, but would really is invisible

The covered place appears faint, but is actually invisible.

If the image is then moved around and only the part revealed by the Panel would be visible. The movement could is controlled by Scrollbars to create a scrollable viewer for a map, say.

If the image is moved, only the portion of the panel is visible. For example, this movement can be controlled by a scroll bar, creating a scrollable viewer for the map.

Implementation

Realize

Masking is implemented using the stencil buffer of the GPU.

The masking is implemented using the GPU's template buffers.

The first Mask element writes a 1 to the stencil buffer All elements below the mask check if rendering, and only render to areas where there are a 1 in the stencil buffer *neste D masks would write incremental bit masks into the buffer, this means that renderable children need to the logical &am P of the stencil values to be rendered.

The first mask element writes 1 to the template buffer, and when rendered, all the elements underneath the mask are checked, only the area of the template buffer is 1 is rendered (this is a bitwise marker, because the template buffer has only one byte, so only 8 layers can be nested at most).

* Nested masks are written to other bits, which means that the child elements that can be rendered need to get the value of the template buffer and render according to certain logic.

Unity2017.1 official Ugui Document translation--mask

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.