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.
在画布的区域内包含所有的UI元素。画布对象拥有一个组件,并且所有的UI元素必须为画布的子物体。

Creating a new UI element, such as an Image using the menu GameObject > UI > Image, automatically creates a Canvas, if there isn’t already a Canvas in the scene. The UI element is created as a child to this Canvas.

创建一个新的UI元素,比如:创建Image,在菜单中的GamObject -> UI-> Image,如果在场景中不存在画布会自动的创建一个画布。即所创建的UI元素会作为其子元素。

Draw order of elements ----画布的元素

UI elements in the Canvas are drawn in the same order they appear in the Hierarchy. The first child is drawn first, the second child next, and so on. If two UI elements overlap, the later one will appear on top of the earlier one.

在层次视图中按一定顺序显示出已创建的UI元素。第一个创建的子物体会显示在第一个,依次往下。
在scene中,如果两个元素重叠,则后创建的一个会显示在另一个上面。

To change which element appear on top of other elements, simply reorder the elements in the Hierarchy by dragging them. The order can also be controlled from scripting by using these methods on the Transform component: SetAsFirstSibling, SetAsLastSibling, and SetSiblingIndex.

在层次视图中,改变元素的顺序可以通过简单的拖拽来改变。同样也可以通过这些方法的脚本组件来改变:SetAsFirstSibling,SetAsLastSibling,SetSiblingIndex。

Render Modes---渲染方式

The Canvas has a Render Mode setting which can be used to make it render in screen space or world space.

画布呈现的渲染方式设置,可以用来使它呈现为屏幕空间或世界空间。

Screen Space - Overlay ----屏幕显示UI

This render mode places UI elements on the screen rendered on top of the scene. If the screen is resized or changes resolution, the Canvas will automatically change size to match this.

这种渲染模式只呈现出UI元素的场景。如果更改屏幕的大小或分辨率,画布会自动的改变大小匹配。

Screen Space - Camera ----摄像机

This is similar to Screen Space - Overlay, but in this render mode, the Canvas is placed a given distance in front of a specified Camera. The UI elements are rendered by this camera, which means that the Camera settings affect the appearance of the UI. If the Camera is set to Perspective, the UI elements will be rendered with perspective, and the amount of perspective distortion can be controlled by the Camera Field of View. If the screen is resized or changes resolution, or the camera frustrum changes, the Canvas will automatically change size to match as well.

在这个渲染模式下,前面的画布上放置一个给定距离的摄像机。则UI元素会被摄像机渲染,意味着相机的设置影响用户界面的外观。如果相机设置为视角,UI元素将呈现的角度来看,和透视失真的数量可以控制摄像机的视野。如果屏幕大小或更改分辨率,或者相机锥范围变化,画布会自动改变大小匹配。

World Space ---世界空间

In this render mode, the Canvas will behave as any other object in the scene. The size of the Canvas can be set manually using its Rect Transform, and UI elements will render in front of or behind other objects in the scene based on 3D placement. This is useful for UIs that are meant to be a part of the world. This is also known as a “diegetic interface”.

此渲染模式下,场景中的任何物体均会被呈现出。互补的大小可以手动设置其矩形位置和UI元素将渲染场景中其他对象的前面或后面。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 本篇文章是基于谷歌有关Graphic的一篇概览文章的翻译:http://source.android.com/de...
    lee_3do阅读 11,988评论 2 21
  • UGUI的目录结构 UGUI包括很多UI工具,但所有的UI工具都会在Canvas(画布)下进行渲染显示。所以当新建...
    紫龙大侠阅读 5,121评论 0 1
  • 有些人二十几岁就死了,但衰老却花了一辈子。其实人死的时候并不是忽然就死掉了,二十几岁的死更像是江河日下。当发现自己...
    十二时辰阅读 2,338评论 0 0
  • 01 母亲又在我们的家庭群里发了一张照片。她和几个闺蜜一起,在老家的玻璃栈道上,拍的照片。 山里在下雨,她打着伞,...
    书虫小言阅读 1,657评论 0 1
  • 摘要: 1通过配菜提升客单价 2配菜要跟对主菜 看起来不起眼的小抱枕,其实是宜家重要的盈利组成。 人山人海的宜家,...
    容止可观阅读 871评论 0 0