Unity UGUI技巧 之 Canvas对屏幕的自适应适配

 时间:2024-10-13 12:07:18

1、CanvasScaler:1)功能描述c盟敢势袂lass in UnityEngine.UIInherits from:EventSystems.UIBehaviourThe Canvas Scaler component is used for controlling the overall scale and pixel density of UI elements in the Canvas. This scaling affects everything under the Canvas, including font sizes and image borders.For a Canvas set to 'Screen Space - Overlay' or 'Screen Space - Camera', the Canvas Scaler UI Scale Mode can be set to Constant Pixel Size, Scale With Screen Size, or Constant Physical Size.Using the Constant Pixel Size mode, positions and sizes of UI elements are specified in pixels on the screen. This is also the default functionality of the Canvas when no Canvas Scaler is attached. However, With the Scale Factor setting in the Canvas Scaler, a constant scaling can be applied to all UI elements in the Canvas.Using the Scale With Screen Size mode, positions and sizes can be specified according to the pixels of a specified reference resolution. If the current screen resolution is larger then the reference resolution, the Canvas will keep having only the resolution of the reference resolution, but will scale up in order to fit the screen. If the current screen resolution is smaller than the reference resolution, the Canvas will similarly be scaled down to fit. If the current screen resolution has a different aspect ratio than the reference resolution, scaling each axis individually to fit the screen would result in non-uniform scaling, which is generally undesirable. Instead of this, the ReferenceResolution component will make the Canvas resolution deviate from the reference resolution in order to respect the aspect ratio of the screen. It is possible to control how this deviation should behave using thescreenMatchModesetting.Using the Constant Physical Size mode, positions and sizes of UI elements are specified in physical units, such as millimeters, points, or picas. This mode relies on the device reporting its screen DPI correctly. You can specify a fallback DPI to use for devices that do not report a DPI.For a Canvas set to 'World Space' the Canvas Scaler can be used to control the pixel density of UI elements in the Canvas.

  • 如何设置迅雷播放.ogm后缀名文件
  • unity3D 如何获取手机屏幕分辨率
  • 如何关闭1K播放器尝试使用硬件解码
  • unity如何关闭开发构建
  • SDL2入门(九)调节texture透明度
  • 热门搜索
    走进西部的手抄报 手抄报传统文化 关于法律的手抄报图片 手抄报小插图 圣诞节手抄报内容英文 关于和平的手抄报 读书手抄报版面设计 数学手抄报一年级 关于科技的手抄报图片 森林防火手抄报内容