Version: 2021.2
Positioning elements
Styling text

Setting background images

UI builder doesn’t have a dedicated “image” element. To create an image in UI Builder, create a regular VisualElement and set its Background > Image to the desired image. The image below displays a preview of the background style properties in the Inspector:

BackgroundStyleProperties
BackgroundStyleProperties
注意
Avoid using the Slice background style properties. You can use Slice to set up 9-slicing on an image. however, it’s specific to the element and not the image. Use the existing 9-slicing support in the 2D Sprite Editor and 2D Sprite assets. See point (2) below.

By default, any regular texture image works in UI Builder. You can add support for additional asset types by installing some optional packages:

  1. Install the com.unity.vectorgraphics package to have the UI Builder expose the ability to assign a VectorImage as a background style on an element.
  2. Install the com.unity.2d.sprite package to have the UI Builder expose the ability to assign a 2D Sprite asset (or sub-asset) as a background style on an element. With the 2D Sprite package installed, you will also have the ability to open the 2D Sprite Editor directly from the Inspector.
Positioning elements
Styling text
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961