Hi guys, I’m trying to use tmp’s richtext to build panels with sprites and texts in lines. But tmp seems to be not able to load sprites from asset bundles and sprite atlases, is there a work-around or better solution?
I’m trying to build a item detail panel which has up to 30 lines, which individually has a sprite and two blocks of text.
I ran into the same issue not too long ago. It seems like TMP only references spriteassets from the Resources folder. The workaround I found was to load the TMP_SpriteAsset from the asset bundle and add it to the fallbackSpriteAssets list of the TMP_Settings.defaultSpriteAsset. Then when using the sprite tag in your text, you use the default sheet (i.e. just use the sprite name, don’t include the sheet name). like so: . When you unload your bundle be sure to remove the asset from the fallbacks
You are correct that TMP expects resources that may be referenced via rich text tags to be located in a Resources folder at the locations specified in the TMP Settings which for Sprite Assets is “Resources/Sprite Assets”.
Assigning the newly Sprite Asset as a general fallback will work as well as assigning it as a fallback to the default sprite asset.
You can also assign a Local Sprite Asset to individual text objects.
The following delegate was also added in the latest release versions of TMP
///
/// Event delegate to allow custom loading of TMP_SpriteAsset when using the <sprite=“Sprite Asset Name”> tag.
///
public static event Func<int, string, TMP_SpriteAsset> OnSpriteAssetRequest;
So whenever a sprite asset is referenced via rich text, the following delegate will be called thus giving you the opportunity to provide one.
I have multiple SpriteAsset which need to be added to TMP_Settings.defaultSpriteAsset.fallbackSpriteAssets.(Load From AssetBundle)
How to use the tag <sprite=“EmojiDynamic” anim=“0,8,10”>?
Or,?
The multiple SpriteAssets need to be loaded From AssetBundle while game run, but do not place to Resource.