Include sprites in text
Create sprite assets to include sprites in rich text tags.
읽는 시간 3분최근 업데이트: 22일 전
To use sprites in your rich text tags, such as emojis, you need a sprite asset. You create sprite assets from atlas textures that contain a set of sprites.

An example atlas texture
You can use as many texture atlases and assets as you want. However, using more than one atlas for a single text element increases draw calls and uses more system resources. As a general rule, if you’re importing multiple sprites, pack them into one atlas to keep draw calls low. Make sure the atlas resolution is high enough for your target platform.
Use the rich text tag to include sprites in your text.
<sprite>Refer to Sprite asset properties reference for more information.
Create a sprite asset
You create sprite assets from atlas textures. Although sprite assets and their source textures are separate entities, you must keep the source textures in the project after you've created the sprite assets.
To create a sprite asset:
-
Select the texture atlas and change the following texture options in the Inspector window:
- Set the Texture Type to Sprite (2D and UI).
- Set the Sprite Mode to Multiple.
-
Select Sprite Editor and divide the texture into individual sprites.
-
To create a new sprite asset, right-click the sprite and select Create > UI Toolkit > Text > Sprite Asset.
-
From thewindow, you can further customize the appearance and names of each glyph. Refer to Sprite Asset properties for more information.Inspector
?
-
Place the sprite asset to the path set in the UITK Text Settings.
Once you have created the sprite asset, you can revert the atlas texture's Texture Type to its original setting.
Use a sprite asset
To use sprites in the rich text tag, reference the sprite asset name and the sprite name as or by index as .
<sprite="assetName" name="spriteName"><sprite="assetName" index=1>You can add the attribute to the tag to tint the sprite with the text object's vertex color. You can also choose a different color by adding a color attribute to the tag, for example: .
tint=1<sprite="assetName" index=1 color=#55FF55FF>For runtime UI, if you have set a sprite asset as the default in the UITK Text Settings, you can omit the asset name as (or shorthand ), or .
<sprite index=1><sprite=1><sprite name="spriteName">Assign and use Unicode for a sprite
You can assign a Unicode to a sprite and use the Unicode directly in your text object instead of the tag.
<sprite>For example, the Unicode for a smiling face emoji is . To assign it to a sprite in your sprite asset:
U+1F60A- In the sprite asset's Inspector window, find the glyph in the Sprite Character Table. You can browse or search by index or name.
- Click the glyph to enable the edit mode.
- In the Unicode box, enter .
+1F60A - Click the Unicode label to save your changes. The Unicode changes to .
0xF1F60A
To use the smiling face emoji in your text object, enter .
\U00F1F60A