# TextMeshProAssetBundle **Repository Path**: giteezzero/TextMeshProAssetBundle ## Basic Information - **Project Name**: TextMeshProAssetBundle - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-02-04 - **Last Updated**: 2021-02-05 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # TextMeshPro With AssetBundle TextMeshPro加载AssetBundle字体测试 TextMeshPro字体默认放在`Resources`相对目录,由于字体有热更的需求,此工程字体打包成AssetBundle测试TextMeshPro能否加载 发现`TMP_Text.cs`是留有自定义加载fontAsset和spriteAsset接口的: ```c# // *** Unity Event Handling *** /// /// Event delegate to allow custom loading of TMP_FontAsset when using the tag. /// public static event Func OnFontAssetRequest; /// /// Event delegate to allow custom loading of TMP_SpriteAsset when using the tag. /// public static event Func OnSpriteAssetRequest; /// /// Event delegate to allow modifying the text geometry before it is uploaded to the mesh and rendered. /// public virtual event Action OnPreRenderText = delegate { }; ``` ``这两个标签字体可以通过上面两个事件委托处理 ```c# ... TMP_Text.OnFontAssetRequest += TMP_Text_OnFontAssetRequest; TMP_Text.OnSpriteAssetRequest += TMP_Text_OnSpriteAssetRequest; ... private TMP_FontAsset TMP_Text_OnFontAssetRequest(int fontHashCode, string fontAssetName) { throw new System.NotImplementedException(); } private TMP_SpriteAsset TMP_Text_OnSpriteAssetRequest(int fontHashCode, string spriteAssetName) { throw new System.NotImplementedException(); } ``` # 注意事项 1. 使用`Fallback Sprite Assets`时需要使用``,此时标签``无效 # 效果图 ![Image text](./images/demo.png) ## 环境 1. Unity 2019.4.18f1 2. TextMeshPro 2.1.1