Unity2017.1官方UGUI文档翻译——Canvas Group
Canvas Group
Canvas组
The Canvas Group can be used to control certain aspects of a whole group of UI elements from one place without needing to handle them each individually. The properties of the Canvas Group affect the GameObject it is on as well as all children.
Canvas Group可以用来控制整个组里UI元素的某些属性,而不用单独去处理。Canvas Group的属性会影响它所在的GameObject以及所有的孩子
Properties
Property: | Function: |
---|---|
Alpha | The opacity of the UI elements in this group. The value is between 0 and 1 where 0 is fully transparent and 1 is fully opaque. Note that elements retain their own transparency as well, so the Canvas Group alpha and the alpha values of the individual UI elements are multiplied with each other. |
Interactable | Determines if this component will accept input. When it is set to false interaction is disabled. |
Block Raycasts | Will this component act as a collider for Raycasts? You will need to call the RayCast function on the graphic raycaster attached to the Canvas. This does not apply to Physics.Raycast. |
Ignore Parent Groups | Will this group also be affected by the settings in Canvas Group components further up in the Game Object hierarchy, or will it ignore those and hence override them? |
属性 | 功能 |
---|---|
Alpha | Canvas Group中UI元素的不透明度, 值介于0和1之间,其中0完全透明,1完全不透明。 请注意,元素也保留自己的透明度,所以Canvas Group的透明度和各个UI元素的Alpha值相乘得到真正的Alpha |
Interactable | 确定该组件是否会接受输入。 当它被设置为false时,交互被禁用 |
Block Raycasts | 这个Canvas Group下的元素是否接收射线,如果为false则该Canvas下面的点击事件都会失效。(PS:如果Canvas选择了Override Sorting可能会导致这个选项失效)这个选项对Physics.Raycast无效 |
Ignore Parent Groups | 这个Canvas Group是否会被上级的(比如父节点、父节点的父节点)Canvas Gropu影响。如果勾选,则会忽略更高级节点的影响 |
Details
详细
Typical uses of Canvas Group are:
Canvas Group的典型用途是:
- Fading in or out a whole window by adding a Canvas Group on the GameObject of the Window and control its Alpha property.
- 通过在窗口的GameObject上添加Canvas Group并控制其Alpha属性来淡入或淡出整个窗口。
- Making a whole set of controls non-interactable (“grayed out”) by adding a Canvas Group to a parent GameObject and setting its Interactable property to false.
- 通过将Canvas组添加到父GameObject并将其Interactable属性设置为false,可以使一组控件不可交互(“变灰”)。
- Making one or more UI elements not block mouse events by placing a Canvas Group component on the element or one of its parents and setting its Block Raycasts property to false.
- 使一个或多个UI元素不会阻塞鼠标事件,方法是在元素或其父元素之一上放置Canvas Group组件,并将其“Block Raycasts”属性设置为false。(虽然该组件叫Canvas Group,但是可以挂在非Canvas的节点上)