Skip to content

I wrote a guide for everyone on how to create their own desired TextMeshPro font assets, and I’ve also prepared two font assets for you all.给大家写了一个如何创建自己想要的TexMeshPro字库的方法,同时给大家准备了两个字库 #840

@vbnshi

Description

@vbnshi

all english text use GPT AutoTranslator
如果你只需要TextMeshPro字库资源直接拉到最下面,接下来我会写教程
If you only need the TextMeshPro font asset files, scroll all the way to the bottom. Next, I’ll explain the tutorial.
如果你需要视频教学可以看这个https://www.bilibili.com/video/BV1zPdNBnE5h/
If you need a video tutorial, you can watch this:https://www.bilibili.com/video/BV1zPdNBnE5h/

1.打开UnityHub→安装unity6000→创建一个项目
2.在左边Hierarchy空白处右键→3D object→Text - TextMeshPro→在弹出TMP Importer窗口之后,把两个导入TMP库的按钮都点一遍
3.把你想要创建的ttf字体拖入unity项目里的Assets窗口→选择上方导航条的window→TextMeshPro→Font Asset Creator
4.填入参数(以下是)
Source Font → 拖入你刚才放进项目的tff字体
Sampling Point Size → Auto Sizing
Padding → 3 or 5 (我用的是3)
Packing Method → Fast
Atlas Resolution → 8192 8192
Character Set → Unicode Range (Hex)
填入你所需要的Unicode
比如我需要英文日文一部分中文和简单符号和中文符号就填入
0020-007E,00A0-00FF,2000-206F,3000-303F,3040-30FF,2600-26FF,FF00-FFEF,4E00-9FA5
Render mode → SDFAA or SDF (我用的是SDFAA)
最后点击 Generate Font Atlas
5.在新生成出来的SDF你可以在项目里进行测试,看看是否有□□□。
6.如果没有问题就右键点击你Assets窗口→Show in Explorer(打开资源管理器)→新建一个名为Editor文件夹,在里面创建一个txt文本,把文本名字改成text.cs
7.在刚新建的text.cs文件里输入以下代码并保存
using System.IO;
using UnityEditor;

/// 打包脚本,放在unity项目下的 Editor 文件夹下,如果没有自己创建一个Editor文件

public class VbnAssetBundlePackage
{
[MenuItem("Vbntool/AssetsBundlePackage")] //加按钮
static void BuildAllAssetsBundles()
{
string folder = "AssetsBundlePackage"; //定义文件夹名字
if (!Directory.Exists(folder)) Directory.CreateDirectory(folder); //不然就创建
BuildPipeline.BuildAssetBundles("AssetsBundlePackage", BuildAssetBundleOptions.None, BuildTarget.StandaloneWindows); //创建AssetBundle
}
}
8.将刚才新建的Editor文件夹移动到项目里的Assets文件夹,如果你操作正确,在你切回unity时会显示一些载入窗口
9.点击你Assets窗口里刚生成的SDF,接着在unity最右下方的AssetBundle点击None→选择New...→给他一个名字(比如arialuni sdf 6000)
10.点击unity上方导航条的Vbntool→AssetsBundlePackage
11.等待读条成功后可以在你的unity项目资源管理器找到一个名叫AssetsBundlePackage文件夹里面的arialuni sdf 6000就是你所需要的TextMeshPro字库文件

If you only need the TextMeshPro font asset files, scroll all the way to the bottom. Next, I’ll explain the tutorial.

1.Open Unity Hub → install Unity 6000 → create a new project.
2.In the empty area of the Hierarchy panel on the left, right-click → 3D Object → Text - TextMeshPro.
When the TMP Importer window pops up, click both buttons to import the TMP libraries.
3.Drag the TTF font you want to create into the Assets window in your Unity project → click Window on the top toolbar → TextMeshPro → Font Asset Creator.
4.Fill in the parameters as follows:

Source Font → Drag in the TTF font you just added to the project
Sampling Point Size → Auto Sizing
Padding → 3 or 5 (I use 3)
Packing Method → Fast
Atlas Resolution → 8192 x 8192
Character Set → Unicode Range (Hex)

Enter the Unicode ranges you need.

For example, if I need English, Japanese, part of Chinese, simple symbols, and Chinese punctuation, I use:

0020-007E,00A0-00FF,2000-206F,3000-303F,3040-30FF,2600-26FF,FF00-FFEF,4E00-9FA5

Render Mode → SDFAA or SDF (I use SDFAA)

Finally, click Generate Font Atlas.

5.You can test the newly generated SDF asset inside the project to check whether there are any missing character boxes (□□□).
If everything works correctly, right-click inside the Assets window → Show in Explorer → create a new folder named “Editor”.
6.Inside it, create a new TXT file and rename it to text.cs.
7.In the newly created text.cs file, paste the following code and save it:
using System.IO;
using UnityEditor;

/// Packaging script. Place it inside the Editor folder under your Unity project.
/// If the Editor folder does not exist, create one yourself.

public class VbnAssetBundlePackage
{
[MenuItem("Vbntool/AssetsBundlePackage")] // Adds a button
static void BuildAllAssetsBundles()
{
string folder = "AssetsBundlePackage"; // Defines the folder name
if (!Directory.Exists(folder)) Directory.CreateDirectory(folder); // Create it if it doesn't exist
BuildPipeline.BuildAssetBundles("AssetsBundlePackage", BuildAssetBundleOptions.None, BuildTarget.StandaloneWindows); // Build the AssetBundle
}
}
8.Move the newly created Editor folder into the Assets folder of your project.
If everything was done correctly, Unity will display some loading/import windows when you switch back to it.
9.Click the generated SDF asset in the Assets window.
Then, at the bottom-right corner in the AssetBundle section, click “None” → choose “New...” → give it a name (for example: arialuni sdf 6000).
10.On the top Unity toolbar, click Vbntool → AssetsBundlePackage.
11.Wait for the process bar to finish successfully.
You can then find a folder named “AssetsBundlePackage” in your Unity project directory.
The file named “arialuni sdf 6000” inside it is the TextMeshPro font asset file you need.

如果你创建出来的字库仍然显示口口口,检查字库文件是否创建正确,文库文件是否在游戏目录,创建的字库里是否包含你所需要的文字标点符号,保证XUnity.AutoTranslator的config设置正确,比如OverrideFontTextMeshPro=NotoSansCJK_sdf_unity6000 or FallbackFontTextMeshPro=NotoSansCJK_sdf_unity6000,同时保证打开EnableTextMeshPro=True,可以把其他[TextFrameworks]都关掉。

如果你创建出来的字体不显示口口口但是使用之后没有任何文字,那就是版本不对,需要针对游戏版本创建字库,查询游戏unity版本并且去下载相应unity版本创建字库。

如果都不行,我也没有办法了,也许并不是TextMeshPro的问题

If the font asset you created still shows □□□, check whether the font asset file was created correctly, whether the font asset file is placed in the game directory, and whether the created font asset contains all the characters and punctuation marks you need.

Also make sure your XUnity.AutoTranslator config is set correctly, for example:

OverrideFontTextMeshPro=NotoSansCJK_sdf_unity6000
or
FallbackFontTextMeshPro=NotoSansCJK_sdf_unity6000

At the same time, make sure EnableTextMeshPro=True is enabled. You can disable the other [TextFrameworks] options.

If the font no longer shows □□□ but no text appears at all after using it, then the version is likely incompatible. You need to create the font asset using the correct Unity version for the game. Check the game's Unity version and download the corresponding Unity version to create the font asset.

If none of this works, then I have no other solution either. Maybe the issue is not related to TextMeshPro.

Download↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
arialuni_sdf_unity6000 applied to 6000.4.5f1 or 6000all(maybe not)
https://mega.nz/file/EwshTBJI#0LCbuWrcoROPJf9hvI58WXxVAVN0-qoFOY_eWvhTMv4

NotoSansCJK_sdf_unity6000 比arialuni_sdf_unity6000字体稍微粗一点我更喜欢 applied to 6000.4.5f1 or 6000all(maybe not)
https://mega.nz/file/8lNDFb6L#VJwIvl0ldEUy36MnzWtPc1QjylW1ze2DK9vDfuBLESI

arialuni_sdf_v2021 applied to 2021 or 6000 the following(maybe not)
https://mega.nz/file/JsFXBLYa#EGvtD5t3EYLzQ83FrNbvrXsZorewynM3D3wNson1PMc

注意以上三个字库文件都只包含了日文中文英文简单的符号以及中文标点符号,如果你需要其他字体只能自己动手创建
Note that the above three font files only include Japanese, Chinese, English, simple symbols, and Chinese punctuation. If you need other fonts, you can only create them yourself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions