UI Builder doesn’t have a dedicated “image” element. To create an image, do the following:
When you set the background image, you must select a supported background image types:
Note: To use a SVG image as a background for a visual element, you must install a package. To do so, in the Package Manager window, install the package com.unity.vectorgraphics
from git URL.
After you have imported an image to your project, for the most intuitive results, Unity recommends you to apply certain import settings for Textures, Sprites, and Vector images before you use them as a background for a visual element in the UI Builder.
The recommended import settings for a Texture image that you use as a background for a visual element:
Property: | Value: | |
---|---|---|
Texture Type | Default | |
Non-Power of 2 | None | |
CompressionA method of storing data that reduces the amount of storage space it requires. See Texture Compression, Animation Compression, Audio Compression, Build Compression. See in Glossary |
None | |
Alpha Is Transparency | true | |
Texture Type | Editor GUI and Legacy GUI | |
Non-Power of 2 | None | |
Compression | None | |
Alpha Is Transparency | true | |
Texture Type | Sprite (2D and UI) | |
Compression | None | |
Alpha Is Transparency | true | |
Sprite Mode | Single | |
MeshThe main graphics primitive of Unity. Meshes make up a large part of your 3D worlds. Unity supports triangulated or Quadrangulated polygon meshes. Nurbs, Nurms, Subdiv surfaces must be converted to polygons. More info See in Glossary Type |
Tight |
The recommended import settings for a Sprite image that you use as a background for a visual element:
Property: | Value: | |
---|---|---|
Texture Type | Sprite (2D and UI) | |
Compression | None | |
Alpha Is Transparency | true | |
Sprite Mode | Multiple if file contains multiple sprites, Single otherwise | |
Mesh Type | Tight |
The recommended import settings for a SVG Vector image that you use as a background for a visual element:
Property: | Value: |
---|---|
Generated Asset Type | UI Toolkit Vector Image |
Tessellation Settings | Basic |
Target Resolution | Lowest value that produces satisfactory results |
Tip:
Generally, you can only 9-slice a regular 2D Sprite. With UI Toolkit however, you can also 9-slice Texture, Render Texture, and SVG Vector images.
To 9-slice an image:
To 9-slice a selected image using USS:
You can also specify the slice values directly in USS, UXML, or C# files for the following properties:
-unity-slice-left
-unity-slice-right
-unity-slice-top
-unity-slice-bottom
Important: