zoukankan      html  css  js  c++  java
  • UGUI手册 Canvas

    参考:

    https://docs.unity3d.com/Manual/UICanvas.html  

    Version: 2017.3

    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.

    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 is shown as a rectangle in the Scene View. This makes it easy to position UI elements without needing to have the Game View visible at all times.

    Canvas uses the EventSystem object to help the Messaging System.

    1.所有的UI元素必须都在Canvas下   2.Canvas就是一个挂有Canvas的Gameobject  3.使用 EventSystem object进行消息分发 

    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.

    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.

    1.ui绘制顺序根据Hierarchy上下来的   2.可通过脚本控制Hierarchy顺序   接口:SetAsFirstSibling, SetAsLastSibling, and 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

    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 in screen space overlay canvasUI in screen space overlay canvas

    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, changes resolution, or the camera frustum changes, the Canvas will automatically change size to match as well.

    UI in screen space camera canvasUI in screen space camera canvas

    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 in world space canvas

    Canvas绘制的三种方式:1.Overlay永远在最上层并且自适应    2.Camera模式 根据Camera的不同变化 Perspective和Ortho模式  3.WorldSpace相当于三维场景中一个Gameobject

    改变自己
  • 相关阅读:
    负载均衡原理与实践详解 第十六篇 负载均衡网络设计 把负载均衡当作二层交换机还是三层路由器
    谈谈我对技术发展的一点感悟
    解析索引中数据列顺序的选择问题
    构建高性能.NET应用之配置高可用IIS服务器第四篇 IIS常见问题之:工作进程回收机制(上)
    关注分离的艺术(The Art of Separation of Concerns)
    如何修改.net framework
    [WPF Documents 之旅]System.Windows.Documents下的Class Diagram
    [转] 依赖注入&控制反转 oC 容器和Dependency Injection 模式(中文版)
    [WPF疑难]如何禁用窗口上的关闭按钮
    关于书写技术探讨性邮件的一点小小的建议
  • 原文地址:https://www.cnblogs.com/sun-shadow/p/8112104.html
Copyright © 2011-2022 走看看