SSRichText
ForkForked from SlipperSoar/SSRichText
SSRichText extends Unity's UGUI text rendering with advanced rich text formatting capabilities. It supports standard tags like bold and italic alongside custom formatting including strikethrough, outlines, shadows, underlines, gradients, and animated GIFs. The package enables interactive elements through clickable links, icons, and GIF animations, making it ideal for UI systems requiring complex text layouts and user engagement features.
Unity Project
Built with Unity 2021.3.27f1c2 · download the source from GitHub

Dependencies (41)
Unity UI 1.0.0Timeline 1.6.5JetBrains Rider Editor 3.0.38com.unity.feature.2d 1.0.0VS Code Editor 1.2.5AI 1.0.0UI 1.0.0VR 1.0.0XR 1.0.0TextMeshPro 3.0.6Unity Version Control 2.0.4Wind 1.0.0Audio 1.0.0Cloth 1.0.0IMGUI 1.0.0Umbra 1.0.0Video 1.0.0Test Framework 1.1.33Physics 1.0.0Terrain 1.0.0Tilemap 1.0.0Visual Scripting 1.8.0Visual Studio Editor 2.0.26Director 1.0.0Vehicles 1.0.0Animation 1.0.0Physics 2D 1.0.0com.unity.modules.androidjni 1.0.0UI Elements 1.0.0Asset Bundle 1.0.0JSON Serialize 1.0.0Screen Capture 1.0.0Particle System 1.0.0Terrain Physics 1.0.0Unity Analytics 1.0.0Image Conversion 1.0.0Unity Web Request 1.0.0Unity Web Request WWW 1.0.0Unity Web Request Audio 1.0.0Unity Web Request Texture 1.0.0Unity Web Request Asset Bundle 1.0.0
README
SSRichText
Unity UGUI RichText
实现思路来自:ZUIRichText
GIF解码思路来自:UnityGif 和 GIF图解和压缩详解
使用的图标来自: 阿里图标库大头贴 阿里图标库多彩小植物
使用的GIF图来自网络
支持
Unity版本:Unity2020或以上经过测试可用,Unity2019及以下或Unity6均未测试
支持的富文本标签:
| 标签 | 效果 | 注释 |
|---|---|---|
| <b></b> | 粗体 | unity原生 |
| <i></i> | 斜体 | unity原生 |
| <size></size> | 大小 | unity原生 |
| <color=red></color> | 颜色 | unity原生 |
| <s></s> | 删除线 | 颜色与字体颜色相同,线宽根据字体大小动态变化 |
| <outline=red></outline> | 描边 | <outline=red>或<outline=#ffffffff>设置颜色 |
| <shadow=rt></shadow> | 阴影 | lt、rt、lb、rb分别表示左上、右上、左下、右下的阴影方向 |
| <icon=xxxx/> | 图标 | 需要配合IconProvider使用 |
| <underline=red></underline> | 下划线 | <underline=red>或<underline=#ffffffff>设置颜色 |
| <link=url></link> | 链接 | url可以填写具体的链接地址 |
| <gif=xxxx/> | 动图 | 需要配合GifDecoder和LoadManager使用 |
| <gradient lt=red rt=red lb=red rb=red></gradient> | 渐变 | 需要填写四个顶点(四角)的颜色 |
支持富文本点击事件:
| 标签 | 事件消息 | 参数 | 备注 |
|---|---|---|---|
| <link=url></link> | OnClick | type, url | - |
| <icon=xxxx/> | OnClick | type, iconName | - |
| <gif=xxxx/> | OnClick | type, gifName | - |
| 默认 | OnClick | type, 文本内容 | 包含outline、underline、shadow以及原生支持的color、size、b、i |
使用方法
通过upm安装custom package
- 打开Unity Package Manager
- 点击+ -> Add package from git URL...
- 填写git URL:https://github.com/SlipperSoar/SSRichText.git?path=/Assets/SSRichText
通过.unitypackage安装
- 前往releases下载.unitypackage
- 拖入UnityEditor
已实现或规划中功能
- outline描边标签
- shadow阴影标签
- underline下划线标签
- icon图标标签
- link标签
- 富文本点击事件
- GIF显示在富文本
- s删除线标签
-
GIF的文本渲染到帧图上(文本扩展块不参与画面渲染) - gradient渐变
效果图

Comments
No comments yet. Be the first!
Sign in to join the conversation
Sign In