Unity2017.1 official Ugui Document translation--canvas

Source: Internet
Author: User

Canvas Canvases

The Canvas is the area and all UI elements should are 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 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.

The Canvas area was shown as a rectangle in the Scene View. This makes it easy-to-position UI elements without needing to has the Game View visible at all times.

Canvas uses the EventSystem object to help the Messaging System.

Canvas is an area where all UI elements should be. Canvas is a gameobject a canvas component is mounted, and all UI elements must be child nodes of the canvas.

If the canvas does not exist in the scene, creating a new UI element, such as creating an image from Gameobject > UI > Image, creates a canvas automatically. The UI element that you create becomes a child node of this canvas.

The canvas area appears as a rectangle in the view scene. This makes it easy to place UI elements without the game view.

Canvas uses EventSystem objects to help the messaging system

Draw Order of elements

The drawing order of the elements

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

To change which element appear on top of other elements, simply reorder the elements in the Hierarchy by dragging them. The order can also is controlled from scripting by using these methods on the Transform component:setasfirstsibling, SetA Slastsibling, and Setsiblingindex.

The UI elements in the canvas are drawn in the same order as they do in hierachy. The first element is drawn first, then the second one, and then in turn. If the 2 elements overlap, the drawing will appear above the preceding drawing.

You can change the order in which elements are drawn by simply dragging the elements in the hierarchy. To change the order of elements in code, you can use the setasfirstsibling, Setaslastsibling, Setsiblingindex methods in the transform component.

Render Modes

Rendering mode

The Canvas has a render Mode setting which can is used to make it into the screen space or world space.

Canvas can set the rendering mode so that he renders it in screen space or world space

Screen Space-overlay

Screen Space-Overlay

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 would automatically change size to match this.

This rendering mode puts the UI above the scene. If the screen resizes or changes the resolution, the canvas will automatically change its size to match (meaning that the canvas will always be the same size as the screen)

UI in screen space overlay canvas

Screen Space-camera

Screen space-camera

This was similar to screen space-overlay, but in this render mode the Canvas was placed a given distance in front of a spe Cified Camera. The UI elements is rendered by this camera, which means, the camera settings affect the appearance of the UI. If the Camera is set to perspective, the UI elements would be rendered with perspective, and the amount of perspective dist Ortion can controlled by the Camera Field of View. If the screen is resized, changes resolution, or the camera frustum changes, the Canvas would automatically change size to Match as well.

This pattern is much like the previous overlay mode, but in this rendering mode, the canvas is placed before a fixed distance of the specified camera. UI elements are rendered by the camera, which means that the settings of the camera affect the performance of the UI. If the camera is set to perspective, the UI elements are rendered in perspective, and the extent of the perspective warp can be controlled by the camera's field of view. If the screen resizes or resolutions or changes the camera's cones, the canvas automatically changes size to match

UI in the screen space camera canvas

World Space

World Space

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

In this rendering mode, the canvas will be like any other object in the scene. Canvas dimensions can be set manually in Recttransform, and UI elements are rendered in front of or behind other objects, depending on the position in the 3D space. This is useful for UI that belongs to a part of the world. This is also known as the "Plot interface."

UI in World space canvas

Unity2017.1 official Ugui Document translation--canvas

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.